2.2.5.5. Normal law

A normal law is defined with a mean \(\mu\) and a standard deviation \(\sigma\), as

\[f(x) = e^{\frac{-(x-\mu)^2}{2\sigma^2}}\times\frac{1}{\sqrt{2\pi\sigma^2}}\]

Uranie code to simulate a normal random variable is:

tds = DataServer.TDataServer("tdssampler", "Sampler Uranie demo")
tds.addAttribute(DataServer.TNormalDistribution("n", 0.0, 1.0))

fsamp = Sampler.TSampling(tds, "lhs", 300)
fsamp.generateSample()  # Create a representative sample

tds.Draw("n")

Figure 2.9 shows the PDF, CDF and inverse CDF generated for different sets of parameters.

../../../_images/TNormalDistribution.png

Figure 2.9 Example of PDF, CDF and inverse CDF for Normal distributions.

Is it also possible to set boundaries to the infinite span of this distribution to create a truncated normal law. This can be done by calling the following method:

tds.getAttribute("n").setBounds(-1.4,2.0)  # truncate the law

The resulting PDF, CDF and inverse CDF, with and without truncation, can be seen, in this case, in Figure 2.10 for a given set of parameters and various boundaries.

../../../_images/TNormalTruncatedDistribution.png

Figure 2.10 Example of PDF, CDF and inverse CDF for a Normal truncated distribution.