Normal distribution#
The Normal (or Gaussian) distribution is a widely used symmetric continuous probability distribution.
In the following, let \(X\) be a random variable that follows a Normal distribution with mean \(\mu_X\) and standard deviation \(\sigma_X\) , and let \(x\) denote a particular outcome of \(X\).
import fesslix as flx
flx.load_engine()
import numpy as np
import fesslix.plot as flx_plot
import matplotlib.pyplot as plt
%matplotlib inline
Random Number Generator: MT19937 - initialized with rand()=784456830;
Random Number Generator: MT19937 - initialized with 1000 initial calls.
Syntax#
- property normal#
Normal distribution
normalis a distribution type (flx_rv_type) for Random variables in Fesslix.- Parametrization:
Parameters of the distribution can be specified as additional key-value pairs in an object of type
flx_rv_config. The following combinations of parameters are accepted:mu,sdcov,val_1,pr_1sd,val_1,pr_1val_1,pr_1,val_2,pr_2
The interpretation of the parameters is:
mu(flxPara): mean valuesd(flxParaPosNo0): standard deviationcov(flxParaPosNo0): coefficient of variationval_1(flxPara):pr_1quantile`pr_1(flxParaPr): probability that the value of the distribution is smaller or equal than val_1val_2(flxPara):pr_2quantile`pr_2(flxParaPr): probability that the value of the distribution is smaller or equal than val_2
Example:
rv_1 = flx.rv({'name':'rv_1', 'type':'normal', 'mu':2., 'sd':5. })
rv_2 = flx.rv({'name':'rv_2', 'type':'normal', 'cov':0.1, 'val_1':25., 'pr_1':0.05 })
rv_3 = flx.rv({'name':'rv_3', 'type':'normal', 'sd':2., 'val_1':25., 'pr_1':0.05 })
rv_4 = flx.rv({'name':'rv_4', 'type':'normal', 'val_1':25., 'pr_1':0.05, 'val_2':32., 'pr_2':0.5 })
rv_lst = [ rv_1, rv_2, rv_3, rv_4 ]
Properties#
- Notation
\(X\sim\mathcal{N}(\mu_X,\sigma_X)\)
- Parameters
\(\mu_X\in\mathbb{R}\), \(\sigma_X\in(0,\infty)\)
- Support
\(x\in\mathbb{R}\)
- Mean
\(\mu_X\)
- Standard deviation
\(\sigma_X\)
- Median
\(\mu_X\)
- Mode
\(\mu_X\)
- Skewness
zero
- Excess kurtosis
zero
- Entropy
\(\frac{1}{2}\ln\left(2\pi e {\sigma_X}^2\right)\)
PDF#
The PDF \(f_X(x)\) of the Normal distribution is commonly expressed in terms of the PDF of the Standard Normal distribution \(\varphi(\cdot)\):
The PDF of a Normal distribution can also be expressed as:
where the mean, standard deviation and scaling constant are:
From the equations above, it follows that \(\lambda_2\) must be positive.
fig, ax = plt.subplots(figsize=(10, 4))
for rv in rv_lst:
flx_plot.draw_pdf(ax, rv, config_dict={'label':rv.get_name()})
ax.set_ylim([0., None])
plt.xlabel(r"$x$")
plt.ylabel(r"$f_X(x)$")
plt.legend()
plt.show()
CDF#
The CDF \(F_X(x)\) of the Normal distribution is typically expressed in terms of the CDF of the Standard Normal distribution \(\Phi(\cdot)\):
fig, ax = plt.subplots(figsize=(10, 4))
for rv in rv_lst:
flx_plot.draw_cdf(ax, rv, config_dict={'label':rv.get_name()})
ax.set_ylim([0., 1.])
plt.xlabel(r"$x$")
plt.ylabel(r"$F_X(x)$")
plt.legend()
plt.show()
Quantile function#
The quantile function of the Normal distribution is:
where \(\Phi^{-1}(\cdot)\) is the quantile function of the standard Normal distribution.
Standardizing Normal random variables#
The Normal random variable \(X\) can be transformed to a Standard Normal distribution \(U\) through:
Conversely, a Normal random variable \(X\) with mean \(\mu_X\) and standard deviation \(\sigma_X\) can be generated from a standard Normal variable as: