-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstudentst_test.go
executable file
·70 lines (65 loc) · 1.94 KB
/
studentst_test.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
package prob
import (
"math"
"testing"
)
// Test at http://keisan.casio.com/exec/system/1180573203
func Test_StudentsT(t *testing.T) {
examples := []distributionTest{
distributionTest{
dist: StudentsT{10.0},
mean: 0.0,
variance: 1.25,
stdDev: 1.118033988749895,
relStdDev: math.NaN(),
skewness: 0.0,
kurtosis: 4.0,
pdf: []inOut{
inOut{ in: 9.0, out: 0.0000020670116801089978 },
inOut{ in: 2.5, out: 0.0269387276282444589776 },
inOut{ in: 4.0, out: 0.00203103391104121595875 },
},
cdf: []inOut{
inOut{ in: 9.0, out: 0.9999979309754751589939 },
inOut{ in: 2.5, out: 0.9842765778816955978753 },
inOut{ in: 4.0, out: 0.9987408336876316538681 },
},
},
// This is a Exponential distribution ;P
distributionTest{
dist: StudentsT{2.0},
mean: 0.0,
variance: math.Inf(1),
stdDev: math.Inf(1),
relStdDev: math.NaN(),
skewness: math.NaN(),
kurtosis: math.NaN(),
pdf: []inOut{
inOut{ in: 9.0, out: 0.00132246096373120901175 },
inOut{ in: 2.5, out: 0.0422006438680479607703 },
inOut{ in: 4.0, out: 0.0130945700219731023037 },
},
cdf: []inOut{
inOut{ in: 9.0, out: 0.9939391699536065658886 },
inOut{ in: 2.5, out: 0.935194139889244595443 },
inOut{ in: 4.0, out: 0.9714045207910316829339 },
},
},
}
if err := testValues(examples); err != nil {
t.Fatal(err)
}
if err := testValues(examples); err != nil {
t.Fatal(err)
}
// Using high degrees of freedom to keep variance low.
// A custom test would be better, but there is no closed form MLE that I am aware of.
sample := StudentsT{15.0}
if err := testSamples(sample); err != nil {
t.Fatal(err)
}
}
func Benchmark_StudentsT(b *testing.B) {
dist := StudentsT{15.0}
runBenchmark(b, dist)
}