-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile_avg_std_standarderror.py
executable file
·59 lines (54 loc) · 1.74 KB
/
file_avg_std_standarderror.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Requires Python2.7
from string import digits
import math
import sys
import statistics
# READS THE XVG FILE
# Need to put script file in same directory as the avg
# This file returns the mean, standard deviation, and standard error for data from determined point to the next (as specific line 19 and 21)
# Output in terminal
linecount = 0
total = 0
mean = 0
summation = []
summationsmaller = 0
standarddeviation = 0
standarderror = 0
fromhere = 1
# CHANGE FROMHERE TO CHANGE THE START POINT
tohere = 12836
# CHANGE TOHERE TO CHANGE THE END POINT
secondlinecount = 0
# This is the name of he file to be opened & analysed.
fileread = str(sys.argv[1])
numbers = 0
with open(fileread) as f:
# YOU WILL NEED TO EDIT THIS FOR YOUR FILE
# What xvg stuff its reading
for line in f:
if "@" not in line:
if "#" not in line:
linesplit = line.split()
linecount = linecount + 1
if linecount >= fromhere and linecount <= tohere:
if len(linesplit) > 1:
numbers = numbers + 1
total = total + float(linesplit[1])
mean = float(total/(numbers))
print("mean is: " + str(mean))
print("N is: " + str(fromhere) + " to " + str(tohere) + " or is actually " + str(tohere - fromhere))
numbers = 0
with open(fileread) as f:
# What xvg stuff its reading
for line in f:
if "@" not in line:
if "#" not in line:
linesplit = line.split()
summation = summation + [float(linesplit[1])]
len(summation)
print("Summation total is: " + str(sum(summation)))
print("Summation total divided by sample number: " + str(sum(summation)/len(summation)))
standarddeviation = statistics.stdev(summation)
print("Standard deviation is: " + str(standarddeviation))
standarderror = standarddeviation/math.sqrt(tohere - fromhere)
print("Standard error is: " + str(standarderror))