Search code examples
pythonscipynormal-distribution

Why is scipy norm different for non-standardized distributions


I have a normal distribution with a mean of 71 and a variance of 20.25. The example is taken from "Heads first statistics".

When I standardise the normal distribution to a mean of zero I get the correct result, but from my understanding of scipy and normal distribution, I should get the same probability for the non-standardised distribution.

from scipy.stats import norm
import math

# prints 0.539337742276
print(norm(71, 20.25).sf(69))

zscore = (69-71) / math.sqrt(20.25)
print(norm(0,1).sf(zscore))
# prints 0.671639356718

Solution

  • Notice that norm is parameterised with the mean and scale, not mean and squared scale. Thus,

    >>> from scipy.stats import norm
    >>> norm(71, pow(20.25,0.5)).sf(69)
    0.6716393567181147
    >>> zscore = (69-71) / pow(20.25,0.5)
    >>> norm(0,1).sf(zscore)
    0.6716393567181147