Skip to content

Instantly share code, notes, and snippets.

@danielrobertson
Created February 27, 2014 05:37
Show Gist options
  • Save danielrobertson/9245007 to your computer and use it in GitHub Desktop.
Save danielrobertson/9245007 to your computer and use it in GitHub Desktop.
Standard deviation
import math
def stddev(numbers):
n = len(numbers)
mean = sum(numbers) / n
dev = [x - mean for x in numbers]
dev2 = [x * x for x in dev]
return math.sqrt(sum(dev2) / n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment