mirror of
https://github.com/gonum/gonum.git
synced 2025-10-21 22:29:30 +08:00
add test for StdScore
This commit is contained in:
28
stat_test.go
28
stat_test.go
@@ -1260,3 +1260,31 @@ func ExampleVariance() {
|
|||||||
// The variance of the samples is 77.5000
|
// The variance of the samples is 77.5000
|
||||||
// The weighted variance of the samples is 111.7941
|
// The weighted variance of the samples is 111.7941
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestStdScore(t *testing.T) {
|
||||||
|
for i, test := range []struct {
|
||||||
|
x float64
|
||||||
|
u float64
|
||||||
|
s float64
|
||||||
|
z float64
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
x: 4,
|
||||||
|
u: -6,
|
||||||
|
s: 5,
|
||||||
|
z: 2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
x: 1,
|
||||||
|
u: 0,
|
||||||
|
s: 1,
|
||||||
|
z: 1,
|
||||||
|
},
|
||||||
|
} {
|
||||||
|
z := StdScore(test.x, test.u, test.s)
|
||||||
|
if math.Abs(z-test.z) > 1e-14 {
|
||||||
|
t.Errorf("StdScore mismatch case %d. Expected %v, Found %v", i, test.z, z)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user