AI Hints
Statistics & Math for ML · Lesson 15 of 138

Standard Deviation

Spread in real units.

⏱ 2 min read▶ Video at 15:51🎓 Free
Watch this lesson in the Statistics & Math for ML courseWatch on YouTube ↗Full Statistics & Math for ML course

The variance has one annoying problem. Because we squared everything, its units are squared too. Points squared, or dollars squared. That's hard to imagine. The fix is simple. Take the square root.

Standard Deviation
From the video: Standard Deviation
  • Variance is in squared units
  • Points squared?
  • Take the square root

The square root of variance

The standard deviation is the square root of the variance. NP dot STD computes it directly. Run it. Our scores have a standard deviation of about eighteen points. Roughly speaking, a typical score is about eighteen points away from the mean.

std.pypython
import numpy as np

scores = np.array([55, 72, 90, 40, 81])

print(np.sqrt(np.var(scores)).round(2))
print(np.std(scores).round(2))
print("sample std:", np.std(scores, ddof=1).round(2))
Output
18.01
18.01
sample std: 20.13

Reading a standard deviation

A small standard deviation means the values huddle close to the mean. A large one means they're spread out. City A from before has a standard deviation under one degree. City B's is over eleven. Standard deviation is the most used measure of spread in all of statistics, and in machine learning.

keyvalue
std√variance
Unitssame as the data
Smallvalues huddle together
Largevalues spread out

Summary

The standard deviation is the square root of the variance, in the same units as the data. Next, percentiles, and where a value ranks.

Key takeaways
  • std = √variance
  • np.std
  • Same units as the data
Next up: Percentiles — where do you rank?