--- myst: substitutions: bloc1: python: 17-20 cpp: 4-5,13-15 bloc2: python: 26-27 cpp: 21-22 bloc3: python: 39-42,45-49 cpp: 6,34-36,39-43 --- (sampler_oat_toatdesign_random_mode)= # Random mode In order to have randomly distributed values over the interval, the example's code needs further modifications. To produce a random sampling, the attributes representing the factors must belong to the TStochasticAttribute family (cf. [](#dataserver_attribute_introducing_tstochastic_attribute)). We thus need to modify the "step 1" of example of [](#sampler_oat_toatdesign_simple_oat) to: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/sampler/use_cases/" + language + "/samplingOATRandom." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc1[language] + "\n" + "```" }} ```{tip} There is no *a priori* relationship between the distribution of the attribute and the nominal value and range of the factor it represents. However, a good practice is to insure that the probability density over the whole factor's range is never null. ``` The "step 2" of the example of [](#sampler_oat_toatdesign_simple_oat) does not need to be modified. The "step 3", on the other hand, becomes: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/sampler/use_cases/" + language + "/samplingOATRandom." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc2[language] + "\n" + "```" }} By choosing the "lhs" mode, we ask for a random sampling over the range of the factor (defined in "step 4"). Here, we also ask for 1000[^random_mode] modifications of each factor. [^random_mode]: This is a ridiculously high number for an OAT design whose aim is, precisely, to provide a small and simple {{doe}}. We do this only to be able to visualise nice histograms ! The rest of the script remains unchanged. We modify the "//display" section in order to visualise histograms of the sampling, instead of a long list of numbers: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/sampler/use_cases/" + language + "/samplingOATRandom." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc3[language] + "\n" + "```" }} ```{tip} The two calls to `draw` are an illustration of the use of the "\_\_modified_att\_\_" attribute. Here, it allows to filter out the data, by keeping only the experiments where the interesting factor is modified. ``` The resulting histograms are shown in figure {numref}`sampler_samplingOATRandom`. The left histogram shows the distribution of data for the "x1" attribute (uniform distribution) and the right, for the "x2" attribute (gaussian distribution). The latter shows how the gaussian distribution is truncated by the choice of the nominal value and the range (the complete code can be found in [](#use_cases_macro_sampler_oat_random)). {{ "```{" "figure" "} " + parent_dir + "/roottest/build/uranie/doc/sampler/use_cases/" + language + "/oat_random/samplingOATRandom.png\n" ":align: center\n" ":name: sampler_samplingOATRandom\n" + figure_scale + "\n" "\n" "Random values for OAT design\n" "```" }}