Skip to content

Instantly share code, notes, and snippets.

@Newky
Last active December 29, 2015 18:49
Show Gist options
  • Save Newky/7713237 to your computer and use it in GitHub Desktop.
Save Newky/7713237 to your computer and use it in GitHub Desktop.
def stdev_sample(n):
diff = sum(n) / len(n)
diff_n_squared = map(lambda x: (x-diff) ** 2, n)
variance = sum(diff_n_squared) / (len(diff_n_squared) -1)
return math.sqrt(variance), variance
stdev_sample([1.23, 1.25, 1.21, 1.55])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment