suppose I have some data that looks like this:
time value
1 1
2 2
3 3
4 4
and it goes to 20,000, how would I get the average and stdev of this data?
1 import sys
2 import os
3 import string
4 import csv
5 import math
6 average = []
7 filename = 'pei1.rg'
8 fin1 = open(filename,"rb")
9 line1 = fin1.readline()
10 line1 = fin1.readline()
11 while line1:
12 line1 = map(string.strip,line1.strip().split())
13 average.append(float(line1[1]))
14 line1 = fin1.readline()
15 #print float(average)/float(count)
16 print "Number of steps: ", len(average)
17 print "Average over entire trajectory: ", float(sum(average))/float(len(average))
18 second = int(len(average)/2)
19 print "Average over second half: ", float(sum(average[second:]))/float(second)
20 sys.exit()
I think this works for calculating averages, but I do not know how to get the stdv from here.