Python for Introductory StatisticsXYZ Homework Edition

⇩ Download ▾

9.2 Normal Probability Distribution

The normal probability distribution with mean μ\mu and standard deviation σ\sigma is given by:

f(x)=1σ2πe(xμ)22σ2f(x)=\frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{(x-\mu)^2}{2\sigma^2}} It is bell shaped and is symmetric about the mean μ\mu.

Interactive figureThe normal curve, with mu and sigma on slidersDrag the Mean mu and Standard deviation sigma sliders.
Function graph showing y = 100*exp(-((x-m)^2)/(2*s^2))/(s*sqrt(2*pi)) and y = 100*exp(-((x-73)^2)/(2*5^2))/(5*sqrt(2*pi)). Adjustable parameters: Mean mu (m) = 78 points, Standard deviation sigma (s) = 8 points. Viewing window: x from 58.38 to 87.62, y from -1.44 to 16.64.
XYZ Graph · viewer build 5edf91b
The book's picture of the normal curve is one curve. This one has both of its parameters on sliders, against a dashed reference fixed at the mu = 73, sigma = 5 exam distribution the rest of this section uses. The vertical axis is the density in PERCENT PER EXAM POINT (100 times f(x)), so the reference curve peaks at 7.98 - 100/(5 x sqrt(2 pi)) - and the area under it is still 100. Drag mu and the curve slides without changing shape; drag sigma and the peak height moves in exact inverse proportion, because the area has to stay 1: at sigma = 4 the peak is 9.97, at sigma = 10 it is 3.99. That trade-off is the thing a single printed bell curve cannot show, and it is what makes a z-score comparable across two different normal distributions.
The normal curve: a bell-shaped density symmetric about the mean, with tick marks at μ − 3σ through μ + 3σ and a horizontal arrow marking one standard deviation σ from the mean to μ + σ.

The syntax for the normal cumulative probability P(X<x)P(X<x) with μ\mu=mean and σ\sigma=std is:

from scipy import stats
stats.norm.cdf(x,mean,std) 

The syntax for inverse normal or pth^{th} percentile (with area to the left of p) and μ\mu=mean and σ\sigma=std is:

from scipy import stats
stats.norm.ppf(p,mean,std) 

Note: The standard normal distribution has a mean μ\mu of zero and standard deviation σ\sigma of one.

Example: In a standard normal distribution what is the probability that the z value is less than 2?

Watch demo video

from scipy import stats
stats.norm.cdf(2,0,1)    #for standard normal mean is zero and std is one
Show expected output
0.9772498680518208

Interpretation: P(z<2)=0.9772498680518208P(z<2)=0.9772498680518208

Example: In a standard normal distribution what is the probability that the z value is between -2 and 2.

P ( 2 < z < 2 ) = P ( z < 2 ) P ( z < 2 ) P(-2<z<2)=P(z<2)-P(z<-2)

=stats.norm.cdf(2,0,1)-stats.norm.cdf(-2,0,1)

from scipy import stats
stats.norm.cdf(2,0,1)-stats.norm.cdf(-2,0,1)
Show expected output
0.9544997361036416

Interpretation: P(2<z<2)=0.9544997361036416P(-2<z<2)=0.9544997361036416

Example: The midterm exam scores in a math class is normally distributed with a mean of 73 and a standard deviation of 5.

P(X>65)=1P(X<65)P(X>65)=1 - P(X<65) =1-stats.norm.cdf(65,73,5)

Watch demo video

from scipy import stats
1-stats.norm.cdf(65,73,5)
Show expected output
0.945200708300442

Interpretation: P(X>65)=0.945200708300442P(X>65)=0.945200708300442

Example: The midterm exam scores in a math class is normally distributed with a mean of 73 and a standard deviation of 5.

P(X<85)P(X<85)=stats.norm.cdf(85,73,5)

from scipy import stats
stats.norm.cdf(85,73,5)
Show expected output
0.9918024640754038

Interpretation: P(X<85)=0.9918024640754038P(X<85)=0.9918024640754038

Example: The midterm exam scores in a math class is normally distributed with a mean of 73 and a standard deviation of 5.

90thpercentile90^{th} \text{percentile} = stats.norm.ppf(.9,73,5)

Watch demo video

from scipy import stats
stats.norm.ppf(.90,73,5)
Show expected output
79.407757827723

Interpretation: Ninety percent of scores are less than or equal to 79.407757827723

Example: The midterm exam scores in a math class is normally distributed with a mean of 73 and a standard deviation of 5.

P ( 70 < X < 90 ) = P ( X < 90 ) P ( X < 70 ) P(70 < X < 90) = P(X<90) - P(X<70)

stats.norm.cdf(90,73,5) - stats.norm.cdf(70,73,5)
Show expected output
0.7254099529842495

Interpretation: P(70<X<90)=0.7254099529842495P(70<X<90)=0.7254099529842495

SciPy.Stats Summary of Probability Distributions

from scipy import stats
procedurescipy.stats
Binomial pdf P(X=x)P(X=x) stats.binom.pmf(k,n,p)
Binomial cdf P(Xx)P(X\le x) stats.binom.cdf(k,n,p)
Normal cdf P(Xx)P(X\le x) stats.norm.cdf(x,mean,std)
Inverse Normal or p-th Percentile stats.norm.ppf(p,mean,std)
t distribution cdf P(Xx)P(X \le x) stats.t.cdf(t,df,0,1)
Inverse t or p-th Percentile stats.t.ppf(p,df,0,1)
chi-square cdf P(χ2ch2)P(\chi^2 \le ch2) stats.chi2.cdf(ch2,k-1)
Inverse chi-square or p-th Percentile stats.chi2.ppf(p,k-1)

Adapted from Python for Introductory Statistics, by Simon Aman (Truman College, City Colleges of Chicago), licensed under CC BY 4.0. Changes were made: reformatted as an accessible XYZ web edition with live in-browser code cells. License: CC-BY-4.0.

These eBooks are a prerelease and are not yet certified conformant with WCAG 2.1 AA or ADA Title II. Every page is built against an automated accessibility gate, and the published editions will meet ADA Title II requirements when they release in late September 2026. If something is unusable, please tell us.