-
Notifications
You must be signed in to change notification settings - Fork 2
/
confidence.go
118 lines (116 loc) · 1.67 KB
/
confidence.go
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package main
// 97.5 critical values from t distribution for varying degrees of freedom,
// from http://www.itl.nist.gov/div898/handbook/eda/section3/eda3672.htm
var tcrit975 = map[int]float64{
1: 12.706,
2: 4.303,
3: 3.182,
4: 2.776,
5: 2.571,
6: 2.447,
7: 2.365,
8: 2.306,
9: 2.262,
10: 2.228,
11: 2.201,
12: 2.179,
13: 2.16,
14: 2.145,
15: 2.131,
16: 2.12,
17: 2.11,
18: 2.101,
19: 2.093,
20: 2.086,
21: 2.08,
22: 2.074,
23: 2.069,
24: 2.064,
25: 2.06,
26: 2.056,
27: 2.052,
28: 2.048,
29: 2.045,
30: 2.042,
31: 2.04,
32: 2.037,
33: 2.035,
34: 2.032,
35: 2.03,
36: 2.028,
37: 2.026,
38: 2.024,
39: 2.023,
40: 2.021,
41: 2.02,
42: 2.018,
43: 2.017,
44: 2.015,
45: 2.014,
46: 2.013,
47: 2.012,
48: 2.011,
49: 2.01,
50: 2.009,
51: 2.008,
52: 2.007,
53: 2.006,
54: 2.005,
55: 2.004,
56: 2.003,
57: 2.002,
58: 2.002,
59: 2.001,
60: 2,
61: 2,
62: 1.999,
63: 1.998,
64: 1.998,
65: 1.997,
66: 1.997,
67: 1.996,
68: 1.995,
69: 1.995,
70: 1.994,
71: 1.994,
72: 1.993,
73: 1.993,
74: 1.993,
75: 1.992,
76: 1.992,
77: 1.991,
78: 1.991,
79: 1.99,
80: 1.99,
81: 1.99,
82: 1.989,
83: 1.989,
84: 1.989,
85: 1.988,
86: 1.988,
87: 1.988,
88: 1.987,
89: 1.987,
90: 1.987,
91: 1.986,
92: 1.986,
93: 1.986,
94: 1.986,
95: 1.985,
96: 1.985,
97: 1.985,
98: 1.984,
99: 1.984,
100: 1.984,
}
// produces 95% confidence interval width from sigma and degrees of freedom.
func conf95(sigma float64, dof int) float64 {
if dof < 1 {
panic("no samples")
}
c, ok := tcrit975[dof]
if !ok {
c = 1.96
}
return sigma * c
}