-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnegbinomial_test.go
executable file
·45 lines (39 loc) · 1.15 KB
/
negbinomial_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
package prob
import "testing"
// Test at http://keisan.casio.com/exec/system/1180573210
func Test_NegBinomial(t *testing.T) {
examples := []distributionTest{
distributionTest{
dist: &NegBinomial{10.0, 0.5},
mean: 10.0,
variance: 20.0,
stdDev: 4.472135954999579392818,
relStdDev: 0.4472135954999579392818,
skewness: 0.6708203932499369089228,
kurtosis: 0.65,
pdf: []inOut{
inOut{ in: 1.0, out: 0.0048828125 },
inOut{ in: 3.0, out: 0.02685546875 },
inOut{ in: 5.0, out: 0.06109619140625 },
inOut{ in: 20.0, out: 0.0093272002413868904114 },
},
cdf: []inOut{
inOut{ in: 1.0, out: 0.005859375 },
inOut{ in: 3.0, out: 0.046142578125 },
inOut{ in: 5.0, out: 0.15087890625 },
inOut{ in: 20.0, out: 0.9786130273714661598206 },
},
},
}
if err := testValues(examples); err != nil {
t.Fatal(err)
}
sample := &NegBinomial{10.0, 0.5}
if err := testSamples(sample); err != nil {
t.Fatal(err)
}
}
func Benchmark_NegBinomial(b *testing.B) {
dist := &NegBinomial{10.0, 0.5}
runBenchmark(b, dist)
}