--- myst: substitutions: bloc1: python: 30-38 cpp: 32-40 bloc2: python: 40-44 cpp: 42-46 bloc3: python: 11,46-60 cpp: 8,48-59 bloc4: python: 62-64 cpp: "61" bloc5: python: "20" cpp: "25" bloc6: python: "22" cpp: "27" bloc7: python: 24-28 cpp: 29-33 bloc8: python: "30" cpp: "35" bloc9: python: 32,33 cpp: 37,38 --- # **$\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 {{tds}} 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.* [](#modeler_module)). This model will enable the creation of the control variate. {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/statistics/" + language + "/compute_quantile_cv." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc1[language] +"\n" + "```" }} A variable that represents the control-variate is added to the {{tds}}. It is built by means of the surrogate model. {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/statistics/" + language + "/compute_quantile_cv." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc2[language] +"\n" + "```" }} The Empirical $\alpha$-quantile of the control variate needs to be evaluated. You can do it with the followings commands: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/statistics/" + language + "/compute_quantile_cv." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc3[language] + "\n" + "```" }} Then, the estimation of the $\alpha$-quantile can be made by using the `computeQuantileCV` method. {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/statistics/" + language + "/compute_quantile_cv." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc4[language] + "\n" + "```" }} ```{admonition} 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 {{tds}} where one of its attributes (sent in parameter) is replaced by a new attribute defined by its law (sent in parameter too). {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/statistics/" + language + "/compute_threshold." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc5[language] + "\n" + "```" }} And then, this new {{tds}} must be collected via the `getTDS` method. {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/statistics/" + language + "/compute_threshold." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc6[language] + "\n" + "```" }} A sampling needs to be generated for this new {{tds}}: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/statistics/" + language + "/compute_threshold." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc7[language] + "\n" + "```" }} Now, the probability of an output variable exceeding threshold can be computed with the `computeThreshold` method. {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/statistics/" + language + "/compute_threshold." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc8[language] + "\n" + "```" }} For information, it is possible to compute the mean and standard deviation of this output variable. {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/statistics/" + language + "/compute_threshold." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc9[language] + "\n" + "```" }} ```{admonition} Summary - `TImportanceSampling` (__TDataServer \*__ tds, **TString** var, **TStochasticAttribute** var_IS) Build a {{tds}}, copy of the {{tds}} *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. ```