diff --git a/stat.go b/stat.go index 7a370976..be139a4f 100644 --- a/stat.go +++ b/stat.go @@ -713,12 +713,12 @@ func Moment(moment float64, x, weights []float64) float64 { return m / sumWeights } -// MomentAt computes the weighted n^th moment of the samples, +// MomentAbout computes the weighted n^th moment of the samples, // E[(x - μ)^N] given a mean to center it on. // No degrees of freedom correction is done. // If weights is nil then all of the weights are 1. If weights is not nil, then // len(x) must equal len(weights). -func MomentAt(moment float64, x []float64, mean float64, weights []float64) float64 { +func MomentAbout(moment float64, x []float64, mean float64, weights []float64) float64 { if weights == nil { var m float64 for _, v := range x { diff --git a/stat_test.go b/stat_test.go index c04143b8..e2c24035 100644 --- a/stat_test.go +++ b/stat_test.go @@ -935,7 +935,7 @@ func TestMoment(t *testing.T) { } } -func TestMomentAt(t *testing.T) { +func TestMomentAbout(t *testing.T) { for i, test := range []struct { x []float64 weights []float64 @@ -957,13 +957,13 @@ func TestMomentAt(t *testing.T) { ans: 1.783625e3, }, } { - m := MomentAt(test.moment, test.x, test.mean, test.weights) + m := MomentAbout(test.moment, test.x, test.mean, test.weights) if math.Abs(test.ans-m) > 1e-14 { - t.Errorf("Moment mismatch case %d. Expected %v, found %v", i, test.ans, m) + t.Errorf("MomentAbout mismatch case %d. Expected %v, found %v", i, test.ans, m) } } - if !Panics(func() { MomentAt(1, make([]float64, 3), 0, make([]float64, 2)) }) { - t.Errorf("MomentAt did not panic with x, weights length mismatch") + if !Panics(func() { MomentAbout(1, make([]float64, 3), 0, make([]float64, 2)) }) { + t.Errorf("MomentAbout did not panic with x, weights length mismatch") } }