Created
October 25, 2018 22:17
-
-
Save kimbo/53b54d97f9e8acf3440293fdbca004cf to your computer and use it in GitHub Desktop.
Standard deviation functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import sqrt | |
test_data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
pstd_dev = lambda data: sqrt(sum([((sum(data) / len(data)) - x)**2 for x in data]) / len(data)) | |
std_dev = lambda data: sqrt(sum([((sum(data) / len(data)) - x)**2 for x in data]) / (len(data) - 1)) | |
print(pstd_dev(test_data)) | |
print(std_dev(test_data)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment