mirror of
https://github.com/gonum/gonum.git
synced 2025-10-18 21:15:23 +08:00
stat: imported stat as a subtree
This commit is contained in:
31
stat/distmv/uniform_test.go
Normal file
31
stat/distmv/uniform_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright ©2017 The gonum Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package distmv
|
||||
|
||||
import (
|
||||
"math"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestUniformEntropy(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
Uniform *Uniform
|
||||
Entropy float64
|
||||
}{
|
||||
{
|
||||
NewUniform([]Bound{{0, 1}, {0, 1}}, nil),
|
||||
0,
|
||||
},
|
||||
{
|
||||
NewUniform([]Bound{{-1, 3}, {2, 8}, {-5, -3}}, nil),
|
||||
math.Log(48),
|
||||
},
|
||||
} {
|
||||
ent := test.Uniform.Entropy()
|
||||
if math.Abs(ent-test.Entropy) > 1e-14 {
|
||||
t.Errorf("Entropy mismatch. Got %v, want %v", ent, test.Entropy)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user