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
TDataServeris 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) tlin = Modeler.TLinearRegression(tds, "rw:r:tu:tl:hu:hl:l:kw", sY, "Dummy") tlin.estimate() tlin.exportFunction("c++", "_SR_rl_", "SRrl") tann = Modeler.TANNModeler(tds, "%s,8,%s" % (sinput,sY) ) tann.train(3, 2, "test") tann.setDrawProgressBar(False) 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 ROOT.gROOT.LoadMacro("_SR_rl_.C") tlfz = Launcher.TLauncherFunction(tds, "SRrl", sinput, "Z") tlfz.setDrawProgressBar(False) tlfz.run()
The Empirical \(\alpha\)-quantile of the control variate needs to be evaluated. You can do it with the followings commands:
tdsza = DataServer.TDataServer( "%s_zalpha" %(tds2.GetName()), "Ex. flowrate") for i in range(nattinput): tdsza.addAttribute( tds2.getAttribute(i)) fsza = Sampler.TSampling(tdsza, "lhs", 6000) fsza.generateSample() tlfrlza = Launcher.TLauncherFunction(tdsza, "SRrl", sinput, "Zrl") tlfrlza.setDrawProgressBar(False) tlfrlza.run() from ctypes import c_double dAlpha = c_double(0.5) dZrla = c_double(0) tdsza.computeQuantile("Zrl", dAlpha, dZrla) print(dZrla)
Then, the estimation of the \(\alpha\)-quantile can be made by using the
computeQuantileCVmethod.dY = c_double(0) rho = c_double(0) 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).
tis = Sampler.TImportanceSampling(tds2, "rw", DataServer.TNormalDistribution("rw_IS", 0.10, 0.015), nS)
And then, this new TDataServer must be collected via the getTDS method.
tdsis = tis.getTDS()
A sampling needs to be generated for this new TDataServer:
sampis = Sampler.TSampling(tdsis,"lhs",nS)
sampis.generateSample()
tlfis = Launcher.TLauncherFunction(tdsis, "flowrateModel", "*", "Y_IS")
tlfis.setDrawProgressBar(False)
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.
ISmean = tis.computeMean("Y_IS")
ISstd = tis.computeStd("Y_IS")
Summary
TImportanceSampling(TDataServer * tds, TString var, TStochasticAttribute var_IS)Build a
TDataServer, copy of theTDataServertds 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.