2.4.4.2. \(\alpha\)-quantile

The \(\alpha\)-quantile can be evaluated by several ways:

  • Control variate,

  • Importance sampling.

Control variate

To estimate the \(\alpha\)-quantile by control variate, you must use the computeQuantileCV method. The procedure to do this estimation is the following:

  • If the control variate is determined in the macro: A TDataServer is necessary and a surrogate model, like “linear regression” or “artificial neural network”, needs to be built from this dataserver and exported into a file (c.f. The Modeler Module). This model will enable the creation of the control variate.

        // Build the SR ( Linear regression + ANN)
        TLinearRegression *tlin = new TLinearRegression(tds,"rw:r:tu:tl:hu:hl:l:kw", sY);
        tlin->estimate();
        tlin->exportFunction("c++", "_SR_rl_", "SRrl");
    
        TANNModeler* tann=new TANNModeler(tds, Form("%s,8,%s",sinput.Data(),sY.Data()));
        tann->train(3, 2, "test");
        tann->setDrawProgressBar(kFALSE);
        tann->exportFunction("c++", "_SR_ann_", "SRann");
    

    A variable that represents the control-variate is added to the TDataServer. It is built by means of the surrogate model.

        //build Z
        gROOT->LoadMacro("_SR_rl_.C");
        TLauncherFunction *tlfz = new TLauncherFunction(tds, "SRrl",sinput,"Z");
        tlfz->setDrawProgressBar(kFALSE);
        tlfz->run();
    

    The Empirical \(\alpha\)-quantile of the control variate needs to be evaluated. You can do it with the followings commands:

        TDataServer *tdsza = new TDataServer( Form("%s_zalpha", tds2->GetName()), "Ex. flowrate");
        for(Int_t i=0; i< nattinput; i++)
            tdsza->addAttribute( tds2->getAttribute(i));
    
        TSampling *fsza = new TSampling(tdsza, "lhs", 6000);
        fsza->generateSample();
    
        TLauncherFunction * tlfrlza = new TLauncherFunction(tdsza, "SRrl", sinput, "Zrl");
        tlfrlza->setDrawProgressBar(kFALSE);
        tlfrlza->run();
    
        tdsza->computeQuantile("Zrl", dAlpha, dZrla);
        cout << dZrla  << endl;
    

    Then, the estimation of the \(\alpha\)-quantile can be made by using the computeQuantileCV method.

        tds->computeQuantileCV("yhat",alpha,"Z",dZrla, dY, rho);
    

Summary: computeQuantileCV

  • computeQuantileCV (TString yname, Double_t alpha, TString zname, Double_t zapha, Double_t& yalpha, Double_t& rho)

    Estimates the \(\alpha\)-quantile (yalpha) of the attribute yname thanks to the control variate zname of empirical \(\alpha\)-quantile zalpha.

Importance sampling

To estimate the \(\alpha\)-quantile by importance sampling, the method computeThreshold needs to be used. The procedure to make this estimation follows.

First, an object TImportanceSampling needs to be created. This object will allow the creation of a copy of the TDataServer where one of its attributes (sent in parameter) is replaced by a new attribute defined by its law (sent in parameter too).

    TImportanceSampling * tis = new TImportanceSampling(tds2,"rw",new TNormalDistribution("rw_IS", 0.10,0.015),nS);

And then, this new TDataServer must be collected via the getTDS method.

    TDataServer *tdsis = tis->getTDS();

A sampling needs to be generated for this new TDataServer:

    TSampling * sampis = new TSampling(tdsis,"lhs",nS);
    sampis->generateSample();
    TLauncherFunction *tlfis = new TLauncherFunction(tdsis,"flowrateModel","*","Y_IS");
    tlfis->setDrawProgressBar(kFALSE);
    tlfis->run();

Now, the probability of an output variable exceeding threshold can be computed with the computeThreshold method.

    ISproba = tis->computeThreshold("Y_IS",seuil);

For information, it is possible to compute the mean and standard deviation of this output variable.

    double ISmean =  tis->computeMean("Y_IS");
    double ISstd =  tis->computeStd("Y_IS");

Summary

  • TImportanceSampling (TDataServer * tds, TString var, TStochasticAttribute var_IS)

    Build a TDataServer, copy of the TDataServer tds where the attribute var is replaced by the stochastic variable var_IS.

  • getTDS ()

    Return the new TDS built by the above constructor.

  • Double_t computeMean (TString u)

    Compute the mean of the u variable.

  • Double_t computeStd (TString u)

    Compute the standard deviation of the u variable.

  • Double_t computeThreshold (TString u, Double_t val)

    Compute the probability of the u variable exceeding the val threshold.