Normal Distribution¶
Table of contents
Density Function¶
The density function of the Normal (Gaussian) distribution:
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.dnorm(x: float, mean: float = 0.0, sd: float = 1.0, log: bool = False) float
Density function of the Normal distribution.
Example
>>> pystats.dnorm(1.645, 0.0, 1.0) 0.10311081109198143
- Parameters
x (float) – A real-valued input.
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The density function evaluated at x.
List Input¶
- pystats.dnorm(x: List[float], mean: float = 0.0, sd: float = 1.0, log: bool = False) List[float]
Density function of the Normal distribution.
Example
>>> pystats.dnorm([-1.0, 0.0, 2.0], 0.0, 1.0) [0.24197072451914342, 0.39894228040143265, 0.05399096651318805]
- Parameters
x (List[float]) – A standard list input.
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of density values corresponding to the elements of x.
Cumulative Distribution Function¶
The cumulative distribution function (CDF) of the Normal (Gaussian) distribution:
where \(\text{erf}(\cdot)\) denotes the Gaussian error function.
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.pnorm(p: float, mean: float = 0.0, sd: float = 1.0, log: bool = False) float
Distribution function of the Normal distribution.
Example
>>> pystats.pnorm(1.645, 0.0, 1.0) 0.9500150944608786
- Parameters
p (float) – A real-valued input.
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
The cumulative distribution function evaluated at p.
List Input¶
- pystats.pnorm(p: List[float], mean: float = 0.0, sd: float = 1.0, log: bool = False) List[float]
Distribution function of the Normal distribution.
Example
>>> pystats.pnorm([-1.0, 0.0, 2.0], 0.0, 1.0) [0.15865525393145705, 0.5, 0.9772498680518208]
- Parameters
p (List[float]) – A standard list input.
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
log (bool) – Return the log-density or the true form.
- Returns
A list of CDF values corresponding to the elements of p.
Quantile Function¶
The quantile function of the log-Normal distribution:
where \(\text{erf}^{-1}(\cdot)\) denotes the inverse Gaussian error function.
Methods for scalar input, as well as for list input, are listed below.
Scalar Input¶
- pystats.qnorm(q: float, mean: float = 0.0, sd: float = 1.0) float
Quantile function of the Normal distribution.
Example
>>> pystats.qnorm(0.95, 0.0, 1.0) 1.6448536269514706
- Parameters
q (float) – A real-valued input.
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
- Returns
The quantile function evaluated at q.
List Input¶
- pystats.qnorm(q: List[float], mean: float = 0.0, sd: float = 1.0) List[float]
Quantile function of the Normal distribution.
Example
>>> pystats.qnorm([0.3, 0.5, 0.95], 0.0, 1.0) [-0.5244005127080409, 0.0, 1.6448536269514706]
- Parameters
q (List[float]) – A standard list input.
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
- Returns
A list of quantiles values corresponding to the elements of q.
Random Sampling¶
Random sampling for the Normal distribution is achieved via the normal_distribution
class from the C++ standard library, imported from <random>
.
Scalar Output¶
- pystats.rnorm(mean: float = 0.0, sd: float = 1.0) float
Random sampling function for the Normal distribution.
Example
>>> pystats.rnorm(0.0, 1.0) 0.2772437359624193
- Parameters
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
- Returns
A pseudo-random draw from the Normal distribution.
List Output¶
- pystats.rnorm(n: int, mean: float = 0.0, sd: float = 1.0) List[float]
Random sampling function for the Normal distribution.
Example
>>> pystats.rnorm(3, 0.0, 1.0) [-0.04796221296447198, -2.165514623383353, 0.7219224921308472]
- Parameters
n (int) – The number of output values.
mean (float) – The mean parameter, a real-valued input.
sd (float) – The standard deviation parameter, a real-valued input.
- Returns
A list of pseudo-random draws from the Normal distribution.