-
Notifications
You must be signed in to change notification settings - Fork 0
/
distr_test.go
61 lines (54 loc) · 1.08 KB
/
distr_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
package crazy
import "testing"
func TestUniform1_2(t *testing.T) {
d := Uniform1_2{CryptoSeeded(NewMT64(), mt64N)}
n := 1 << 28
if testing.Short() {
n = 1 << 20
}
for i := 0; i < n; i++ {
if x := d.Next(); x < 1 || x >= 2 {
t.Fail()
}
}
}
func TestUniform0_1(t *testing.T) {
d := Uniform0_1{CryptoSeeded(NewMT64(), mt64N)}
n := 1 << 28
if testing.Short() {
n = 1 << 20
}
for i := 0; i < n; i++ {
if x := d.Next(); x < 0 || x >= 1 {
t.Fail()
}
}
}
func BenchmarkUniform1_2(b *testing.B) {
d := Uniform1_2{CryptoSeeded(NewMT64(), mt64N)}
b.ResetTimer()
for n := 0; n < b.N; n++ {
_ = d.Next()
}
}
func BenchmarkUniform0_1(b *testing.B) {
d := Uniform0_1{CryptoSeeded(NewMT64(), mt64N)}
b.ResetTimer()
for n := 0; n < b.N; n++ {
_ = d.Next()
}
}
func BenchmarkUniform(b *testing.B) {
d := Uniform{CryptoSeeded(NewMT64(), mt64N), -1, 1}
b.ResetTimer()
for n := 0; n < b.N; n++ {
_ = d.Next()
}
}
func BenchmarkUniform1_2Minus1(b *testing.B) {
d := Uniform1_2{CryptoSeeded(NewMT64(), mt64N)}
b.ResetTimer()
for n := 0; n < b.N; n++ {
_ = d.Next() - 1
}
}