scipy.stats.norm.cdf() returns the area under a normal-distribution curve from negative infinity up to a chosen value x. Pass x, the mean, and the standard deviation. section 4.5
Use the function to answer probability questions:
- Find the probability below an upper bound: norm.cdf(63, 64, 3) returns 0.3694. section 4.5
- Find a middle range by subtracting cumulative areas: norm.cdf(63, 64, 3) - norm.cdf(61, 64, 3) returns 0.2108, or 21.08%. section 4.5
Golden retriever weights
Assuming weights have mean 64 pounds and standard deviation 3 pounds, calculate the chance of a dog weighing between 61 and 63 pounds by subtracting the two CDF values. The result is about 21.08%. section 4.5
from scipy.stats import norm
mu, sigma = 64, 3
area = norm.cdf(63, mu, sigma) - norm.cdf(61, mu, sigma)
print(f"Area between 61 and 63: {area:.4f}")
# Area between 61 and 63: 0.2108
The listing shows the complete two-call subtraction used to calculate the probability between 61 and 63 pounds. section 4.5

