Python – 68-95-99.7 rule in Statistics

The Empirical Rule(also called the 68-95-99.7 Rule or the Three Sigma Rule) states that for any normal distribution, we have the following observations :

  • 68% of the observed values lie between 1 standard deviation around the mean : (\mu-\sigma)\ to\ (\mu+\sigma)
  • 95% of the observed values lie between 2 standard deviations around the mean : (\mu-2\sigma)\ to\ (\mu+2\sigma)
  • 99.7% of the observed values lie between 3 standard deviation around the mean : (\mu-3\sigma)\ to\ (\mu+3\sigma)

Below is a standard normal distribution graph with (mean = 0 and standard deviation = 1), illustrating the Empirical Rule.

We, can verify this using functions provided by Python’s SciPy module.

We can use the cdf() function of the scipy.stats.norm module to calculate the cumulative probability(area under a distribution curve).

Syntax : cdf(x, mean, SD)
Parameters :

  • x : value up to which cumulative probability is to be calculated
  • mean : mean of the distribution
  • SD : standard deviation of the distribution

Below is the implementation :





import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import norm
# setting the values of
# mean and S.D.
mean = 0
SD = 1
# value of cdf between one, two
# and three S.D. around the mean
one_sd = norm.cdf(SD, mean, SD) - norm.cdf(-SD, mean, SD)
two_sd = norm.cdf(2 * SD, mean, SD) - norm.cdf(-2 * SD, mean, SD)
three_sd = norm.cdf(3 * SD, mean, SD) - norm.cdf(-3 * SD, mean, SD)
# printing the value of fractions
# within each band
print("Fracton of values within one SD =", one_sd)
print("Fracton of values within two SD =", two_sd)
print("Fracton of values within three SD =", three_sd)


Output :

Fracton of values within one SD = 0.6826894921370859
Fracton of values within two SD = 0.9544997361036416
Fracton of values within three SD = 0.9973002039367398

Hence, we see that the fraction of values are almost equal to 0.65, 0.95 and 0.997. Thus, the empirical Rule is verified.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.