-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtex.py
32 lines (25 loc) · 774 Bytes
/
tex.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
from math import *
def makeRow(num,row):
return num + " & " + row + "\\\\\n"
def ztable(l,s):
body = [makeRow(str(x),str(y)) for (x,y) in zip(range(1,1 + len(l)), l)]
numcols = 0
if len(body) > 0: numcols = len(body[0].split('&'))
if numcols == 0: return ''
table = '\\begin{tabular}{|' + (numcols*'c|') + '}\n' + \
'\\hline\n' + \
'Trial & ' + s + '\\\n' + \
'\\hline\n' + \
''.join(body) + \
'\\hline\n' + \
'\\end{tabular}\n'
return table
def ztable_list(ls,s):
return ztable([' & '.join(map(str,l)) for l in ls],' & '.join(s))
def mean(l):
return (1.0*sum(l))/len(l)
def variance(l):
m = mean(l)
return sum([(x-m)**2 for x in l])/len(l)
def stddev(l):
return sqrt(variance(l))