mirror of
https://github.com/gonum/gonum.git
synced 2025-10-15 19:50:48 +08:00
stat/all: reduce random size and test tolerance to decrease testing t… (#181)
* stat/all: reduce random size and test tolerance to decrease testing time. We were generating a lot of random numbers, which is slow. Decrease the size of those random numbers, and in some cases increase the tolerance to compensate. In a couple cases, pull out code from testFullDist to allow for more fine-grained testing. This decrases: distmat from 4.5s to 0.5s distmv from 24.8s to 9s distuv from 65.2s to 13s samplemv from 2.8s to 1.2s sampleuv from 3.5s to 2.1s
This commit is contained in:
@@ -59,11 +59,11 @@ func TestRejection(t *testing.T) {
|
||||
target := distuv.Normal{Mu: trueMean, Sigma: 2}
|
||||
proposal := distuv.Normal{Mu: 0, Sigma: 5}
|
||||
|
||||
nSamples := 100000
|
||||
nSamples := 20000
|
||||
x := make([]float64, nSamples)
|
||||
Rejection(x, target, proposal, 100, nil)
|
||||
ev := stat.Mean(x, nil)
|
||||
if math.Abs(ev-trueMean) > 1e-2 {
|
||||
if math.Abs(ev-trueMean) > 2e-2 {
|
||||
t.Errorf("Mean mismatch: Want %v, got %v", trueMean, ev)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user