add test for StdScore

This commit is contained in:
Jonathan J Lawlor
2014-10-31 00:00:58 -04:00
parent 29c0aab8c7
commit 137309c26e

View File

@@ -1260,3 +1260,31 @@ func ExampleVariance() {
// The variance of the samples is 77.5000
// 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)
}
}
}