All formulas

Probability distributions

Normal probability density

prob.normal-pdfAlso called normal pdf, gaussian pdf, normal density, gaussian density

f(x)=1σ2πexp⁡(−(x−μ)22σ2)f(x) = \frac{1}{\sigma\sqrt{2\pi}} \exp\left(-\frac{(x - \mu)^2}{2\sigma^2}\right)

Density of the normal distribution with mean μ and standard deviation σ.

Notation

xx

the point at which the density is evaluated

x ∈ ℝ

μ\mu

mean (location)

μ ∈ ℝ

σ\sigma

standard deviation (scale)

σ > 0

f(x)f(x)

Result: the density at x

scalar

Worked examples

Each result is solved exactly and confirmed by two independent computations.

  1. Given

    x=0,μ=0,σ=1x = 0, \mu = 0, \sigma = 1

    Result

    f(x)=22π\displaystyle f(x) = \frac{\sqrt{2}}{2 \sqrt{\pi}}

    ≈ 0.398942280401

  2. Given

    x=1,μ=0,σ=1x = 1, \mu = 0, \sigma = 1

    Result

    f(x)=22πe12\displaystyle f(x) = \frac{\sqrt{2}}{2 \sqrt{\pi} e^{\frac{1}{2}}}

    ≈ 0.241970724519

  3. Given

    x=3,μ=1,σ=2x = 3, \mu = 1, \sigma = 2

    Result

    f(x)=24πe12\displaystyle f(x) = \frac{\sqrt{2}}{4 \sqrt{\pi} e^{\frac{1}{2}}}

    ≈ 0.12098536226

Common mistakes

  • Treats σ as the variance

    The code uses its σ argument where σ2 belongs, as if the parameter were the variance.

    Fix: Pass the standard deviation, or take the square root of the variance before using it.

  • Drops the 1/2 in the exponent

    The exponent is −(x − μ)2/σ2 instead of −(x − μ)2/(2σ2).

    Fix: Divide the squared deviation by 2σ2.

  • Normalizing constant omits σ

    The density is divided by √(2π) but not by σ, so it does not integrate to one unless σ = 1.

    Fix: Divide by σ√(2π).

Source

  • NIST/SEMATECH e-Handbook, §1.3.6.6.1

    NIST/SEMATECH e-Handbook of Statistical Methods. https://www.itl.nist.gov/div898/handbook/ Last updated 2022-04-27. doi:10.18434/M32189

    doi.org