@@ -46,7 +46,7 @@ func nearEqual(a, b, closeEnough, maxError float64) bool {
46
46
return absDiff / max (math .Abs (a ), math .Abs (b )) < maxError
47
47
}
48
48
49
- var testSeeds = []int64 {1 , 1754801282 , 1698661970 , 1550503961 }
49
+ var testSeeds = []uint64 {1 , 1754801282 , 1698661970 , 1550503961 }
50
50
51
51
// checkSimilarDistribution returns success if the mean and stddev of the
52
52
// two statsResults are similar.
@@ -104,16 +104,16 @@ func checkSampleSliceDistributions(t *testing.T, samples []float64, nslices int,
104
104
// Normal distribution tests
105
105
//
106
106
107
- func generateNormalSamples (nsamples int , mean , stddev float64 , seed int64 ) []float64 {
108
- r := New (NewSource ( seed ))
107
+ func generateNormalSamples (nsamples int , mean , stddev float64 , seed uint64 ) []float64 {
108
+ r := New (NewPCG ( seed , seed ))
109
109
samples := make ([]float64 , nsamples )
110
110
for i := range samples {
111
111
samples [i ] = r .NormFloat64 ()* stddev + mean
112
112
}
113
113
return samples
114
114
}
115
115
116
- func testNormalDistribution (t * testing.T , nsamples int , mean , stddev float64 , seed int64 ) {
116
+ func testNormalDistribution (t * testing.T , nsamples int , mean , stddev float64 , seed uint64 ) {
117
117
//fmt.Printf("testing nsamples=%v mean=%v stddev=%v seed=%v\n", nsamples, mean, stddev, seed);
118
118
119
119
samples := generateNormalSamples (nsamples , mean , stddev , seed )
@@ -161,16 +161,16 @@ func TestNonStandardNormalValues(t *testing.T) {
161
161
// Exponential distribution tests
162
162
//
163
163
164
- func generateExponentialSamples (nsamples int , rate float64 , seed int64 ) []float64 {
165
- r := New (NewSource ( seed ))
164
+ func generateExponentialSamples (nsamples int , rate float64 , seed uint64 ) []float64 {
165
+ r := New (NewPCG ( seed , seed ))
166
166
samples := make ([]float64 , nsamples )
167
167
for i := range samples {
168
168
samples [i ] = r .ExpFloat64 () / rate
169
169
}
170
170
return samples
171
171
}
172
172
173
- func testExponentialDistribution (t * testing.T , nsamples int , rate float64 , seed int64 ) {
173
+ func testExponentialDistribution (t * testing.T , nsamples int , rate float64 , seed uint64 ) {
174
174
//fmt.Printf("testing nsamples=%v rate=%v seed=%v\n", nsamples, rate, seed);
175
175
176
176
mean := 1 / rate
@@ -398,7 +398,7 @@ func encodePerm(s []int) int {
398
398
399
399
// TestUniformFactorial tests several ways of generating a uniform value in [0, n!).
400
400
func TestUniformFactorial (t * testing.T ) {
401
- r := New (NewSource ( testSeeds [ 0 ] ))
401
+ r := New (NewPCG ( 1 , 2 ))
402
402
top := 6
403
403
if testing .Short () {
404
404
top = 3
@@ -436,8 +436,8 @@ func TestUniformFactorial(t *testing.T) {
436
436
// See https://en.wikipedia.org/wiki/Pearson%27s_chi-squared_test and
437
437
// https://www.johndcook.com/Beautiful_Testing_ch10.pdf.
438
438
nsamples := 10 * nfact
439
- if nsamples < 500 {
440
- nsamples = 500
439
+ if nsamples < 1000 {
440
+ nsamples = 1000
441
441
}
442
442
samples := make ([]float64 , nsamples )
443
443
for i := range samples {
@@ -476,11 +476,11 @@ func TestUniformFactorial(t *testing.T) {
476
476
var Sink uint64
477
477
478
478
func testRand () * Rand {
479
- return New (NewSource ( 1 ))
479
+ return New (NewPCG ( 1 , 2 ))
480
480
}
481
481
482
482
func BenchmarkSourceUint64 (b * testing.B ) {
483
- s := NewSource ( 1 )
483
+ s := NewPCG ( 1 , 2 )
484
484
var t uint64
485
485
for n := b .N ; n > 0 ; n -- {
486
486
t += s .Uint64 ()
0 commit comments