printing - Print Standard Deviation from a list in python 2.5.3.0 -


trying figure out how standard deviation list. ive looked examples , reason cannot them work. total, median, , mean fine, standard deviation giving errors , not sure how print.

this code have created, yes know can shortened. first go around.

i following error

attributeerror: 'module' object has no attribute 'stdev'                 

this code have created, yes know can shortened. first go around.

num1 = int(input("insert first number")) num2 = int(input("insert next number")) num3 = int(input("insert next number")) num4 = int(input("insert next number")) num5 = int(input("insert next number")) num6 = int(input("insert next number")) num7 = int(input("insert next number")) num8 = int(input("insert next number")) num9 = int(input("insert next number")) num10 = int(input("insert last number"))  x = ([num1, num2, num3, num4, num5, num6, num7, num8, num9, num10])  total = sum(x) print (total)  mean = total / 10 print (mean)  median = sorted(x)[len(x)//2] print (int(median))  import stat stdeviation = stat.stdev(x) print (stdeviation) 

sorry, module stat related posix system call stat not statistics. anyway standard deviation square root of average squared difference mean. can directly. well, want compute "sample" standard deviation uses "bessel's correction": not average squared difference (dividing number of samples), rather squared difference divided 1 less number of samples.

to put briefly: sample standard deviation, python 3 calls statistics.stdev, this:

math.sqrt(sum([(val - mean)**2 val in x])/(len(x) - 1)) 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -