Skip to content

Instantly share code, notes, and snippets.

@albertyumol
Created October 23, 2019 01:32
Show Gist options
  • Save albertyumol/88ea806ad551a42562a80bb159db6ce2 to your computer and use it in GitHub Desktop.
Save albertyumol/88ea806ad551a42562a80bb159db6ce2 to your computer and use it in GitHub Desktop.
Calculate the standard deviation.
import numpy as np
def standard_deviation(x):
x_bar = np.mean(x)
N = len(x)
deviation_mean = [x_i - x_bar for x_i in x]
return np.sqrt(np.dot(deviation_mean, deviation_mean) / N)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment