--- myst: substitutions: bloc: stocha: python: 6-16 cpp: 5-15 trunc: python: "18" cpp: "17" code: python: "addDistribution(statt, weight=1.)" cpp: "int addDistribution(URANIE::DataServer::TStochasticAttribute *statt, double weight=1.);" --- ```{include} /../core/dataserver/attribute/introducing_tstochastic_attribute/compose_equation.md ``` {{ uranie }} code to simulate a composition of three normally-distributed laws (with their own statistical properties): {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/attribute/" + language + "/compose." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc["stocha"][language] + "\n" + "```" }} ```{include} /../core/dataserver/attribute/introducing_tstochastic_attribute/compose_figure.md ``` Is it also possible to set boundaries to the infinite span of this distribution, if it is created from at least one infinite-based law, to create a truncated composed law. This can be done by calling the following method: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/attribute/" + language + "/compose." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc["trunc"][language] + "\n" + "```" }} The resulting PDF, CDF and inverse CDF, with and without truncation, can be seen, in this case, in {numref}`dataserver_tcompose_trunc_distribution` for a given set of parameters and various boundaries. {{ "```{" "figure" "} " + parent_dir + "/usermanual/dataserver/figures/TComposedNormalTruncatedDistribution.png\n" ":align: center\n" ":name: dataserver_tcompose_trunc_distribution\n" + figure_scale + "\n" "\n" "Example of PDF, CDF and inverse CDF for a truncated composed distribution made out of three normal distributions with respective weights.\n" "```" }} The only specific method that is new for the composition is the `addDistribution` method whose signature is the following one: {{ "```{code} " + language + "\n" + code[language] + "\n" + "```" }} The first element is a pointer to a `TStochasticAttribute` (so any object that is an instance of a class that derives form it). The second one is the weight (which is 1 by default) and which is the $\omega$ constant written in the formula above. ```{warning} The theoretical element (mean, standard deviation and mode) can not always be measured for certain stochastic distribution (see the Cauchy's one for instance). - If one wants to add such a distribution in a composed law, a warning exception should pop-up to state that theoretical properties can not be estimated. - As for the mode, several distributions prevent from having a single-point mode estimation (for instance the Uniform distribution). The mode estimation should then be taken with great care. ```