Menu
CoddyTech

The 68-95-99.7 Rule

Part of the Statistics for ML section of Coddy's Machine Learning journey. Lesson 10 of 64.

In normal data, the std tells you what share lies how far from the mean. Coffee pours, mean 250 ml, std 5 ml:

A bell curve of coffee pours centered on 250 ml, shaded darkest from 245 to 255, lighter out to 240 and 260, lightest to 235 and 265. Brackets read 68% within 1 std, 95% within 2 std, 99.7% within 3 std

That is the 68-95-99.7 rule. Check it on 10,000 simulated cups: a mask counts those within 1 std.

rng = np.random.default_rng(1)
cups = rng.normal(250, 5, size=10000)
within1 = (cups > 245) & (cups < 255)
print(within1.sum() / cups.size)

This prints:

0.6868

For the share below any value, stats.norm.cdf(x, mean, std) gives the area left of x: stats.norm.cdf(260, 250, 5) is 0.977.

A pour beyond 3 std happens 3 times in 1,000: rare enough to flag before it reaches a model.

challenge icon

Challenge

Easy

A lab ran 5,000 bulbs until they burned out. life holds their hours, and the program reads h. Using the mean and std (np.std) of life, print these shares as percents (1 decimal):

  1. within 1 std of the mean,
  2. within 2 std,
  3. below h, counted,
  4. below h, by the normal curve.

For another batch and the input 1100:

Within 1 std: 67.6%
Within 2 std: 95.7%
Below 1100 hours, counted: 10.2%
Below 1100 hours, normal curve: 10.1%

Try it yourself

import numpy as np
from scipy import stats

# Don't change the lines below
rng = np.random.default_rng(12)
life = np.round(rng.normal(1200, 100, size=5000))
h = int(input())

# Write your code below
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Statistics for ML

Practice on your own: Online Python compiler