mirror of
https://github.com/gonum/gonum.git
synced 2025-10-23 15:13:31 +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:
@@ -4,7 +4,10 @@
|
||||
|
||||
package distuv
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"sort"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLognormal(t *testing.T) {
|
||||
for i, dist := range []LogNormal{
|
||||
@@ -21,6 +24,21 @@ func TestLognormal(t *testing.T) {
|
||||
Sigma: 0.01,
|
||||
},
|
||||
} {
|
||||
testFullDist(t, dist, i, true)
|
||||
f := dist
|
||||
tol := 1e-2
|
||||
const n = 1e5
|
||||
x := make([]float64, n)
|
||||
generateSamples(x, f)
|
||||
sort.Float64s(x)
|
||||
|
||||
checkMean(t, i, x, f, tol)
|
||||
checkVarAndStd(t, i, x, f, tol)
|
||||
checkEntropy(t, i, x, f, tol)
|
||||
checkExKurtosis(t, i, x, f, 2e-1)
|
||||
checkSkewness(t, i, x, f, 5e-2)
|
||||
checkMedian(t, i, x, f, tol)
|
||||
checkQuantileCDFSurvival(t, i, x, f, tol)
|
||||
checkProbContinuous(t, i, x, f, 1e-10)
|
||||
checkProbQuantContinuous(t, i, x, f, tol)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user