/
fastErrorTest.py
42 lines (36 loc) · 1.18 KB
/
fastErrorTest.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
from errorProp import Distribution, FastDistribution
raw = '''
a b a error b error
1 8 0.1 0.1
2 5 0.1 0.1
3 8 0.1 0.1
4 5 0.1 0.1
4 3 0.1 0.1
'''
dists = Distribution.fromString(raw, 150)
fastDists = Distribution.toFastDists(dists)
(d1, d2) = (fastDists[2]['a'], fastDists[2]['b'])
(realD1, realD2) = (dists[2]['a'], dists[2]['b'])
print('-------getErrorBounds Initial Check---------')
print(d1.getErrorBounds(1), d2.getErrorBounds(1))
print(realD1.getErrorBounds(1), realD2.getErrorBounds(1))
print('-------Addition Check----------')
a1 = d1 + d2
realA1 = realD1 + realD2
print(a1.getErrorBounds(1))
print(realA1.getErrorBounds(1))
print('-------Multiplication Check---------')
m1 = d1*d2
realM1 = realD1*realD2
print(m1.getErrorBounds(1))
print(realM1.getErrorBounds(1))
print('-------Negation Check----------')
n1 = -d1
realN1 = -realD1
print(n1.getErrorBounds(1))
print(realN1.getErrorBounds(1))
pts = [[k['a'], k['b']] for k in fastDists]
realPts = [[k['a'], k['b']] for k in dists]
print('--------Linear Regression Check----------')
print([x.getErrorBounds(1) for x in [*FastDistribution.linearRegression(pts)]])
print([x.getErrorBounds(1) for x in [*Distribution.linearRegression(realPts)]])