Sunday, May 24, 2009

Standard Deviation of the Mean, v 1.0

A week ago, I was writing a physics lab and had to calculate Standard Deviation of the Mean for like 5 different sets of 7 data points, so I was feeling lazy. So i probably took more time in doing it, but I coded up a standardDeviation.py file to do it for me. here's version 1 right now ----
# Standard Deviation of the Mean calculator
# Created 5.17.2009, by Douglas W. Selby (selby.douglas@gmail.com)
# Version 1.0

from math import *
def main():
n = input("How many entries? ")
i = 1
average = 0
entryList = []
while(i<=n):
entry = input("entry? ")
entryList.append(entry)
print entryList
average = average + entry
i = i+1

average = average/n
i=0
sum = 0
while(i<=n-1):
sum = sum + (entryList[i]-average)**2
i = i+1

deviation = sqrt(sum/(n-1))
print "Standard Deviation of the Mean = ", deviation

main()

No comments: