stat/distuv: move destination to first position
MODIFY
stat/distuv/exponential.go
stat/distuv/exponential.go
@@ -72,7 +72,7 @@ func (Exponential) ExKurtosis() float64 {
// If weights is not nil, then the len(weights) must equal len(samples).
func (e *Exponential) Fit(samples, weights []float64) {
suffStat := make([]float64, e.NumSuffStat())
- nSamples := e.SuffStat(samples, weights, suffStat)
+ nSamples := e.SuffStat(suffStat, samples, weights)
e.ConjugateUpdate(suffStat, nSamples, make([]float64, e.NumSuffStat()))
}
@@ -201,7 +201,7 @@ func (e Exponential) StdDev() float64 {
//
// If weights is nil, the weights are assumed to be 1, otherwise panics if
// len(samples) != len(weights). Panics if len(suffStat) != NumSuffStat().
-func (Exponential) SuffStat(samples, weights, suffStat []float64) (nSamples float64) {
+func (Exponential) SuffStat(suffStat, samples, weights []float64) (nSamples float64) {
if len(weights) != 0 && len(samples) != len(weights) {
panic(badLength)
}

MODIFY
stat/distuv/general_test.go
stat/distuv/general_test.go
@@ -101,11 +101,11 @@ func testConjugateUpdate(t *testing.T, newFittable func() ConjugateUpdater) {
incWeights = test.weights[j : j+1]
allWeights = test.weights[0 : j+1]
}
- nsInc := incDist.SuffStat(test.samps[j:j+1], incWeights, stats)
+ nsInc := incDist.SuffStat(stats, test.samps[j:j+1], incWeights)
incDist.ConjugateUpdate(stats, nsInc, prior)
allDist := newFittable()
- nsAll := allDist.SuffStat(test.samps[0:j+1], allWeights, stats)
+ nsAll := allDist.SuffStat(stats, test.samps[0:j+1], allWeights)
allDist.ConjugateUpdate(stats, nsAll, make([]float64, allDist.NumParameters()))
if !parametersEqual(incDist.parameters(nil), allDist.parameters(nil), 1e-12) {
t.Errorf("prior doesn't match after incremental update for (%d, %d). Incremental is %v, all at once is %v", i, j, incDist, allDist)
@@ -113,7 +113,7 @@ func testConjugateUpdate(t *testing.T, newFittable func() ConjugateUpdater) {
if test.weights == nil {
onesDist := newFittable()
- nsOnes := onesDist.SuffStat(test.samps[0:j+1], ones(j+1), stats)
+ nsOnes := onesDist.SuffStat(stats, test.samps[0:j+1], ones(j+1))
onesDist.ConjugateUpdate(stats, nsOnes, make([]float64, onesDist.NumParameters()))
if !parametersEqual(onesDist.parameters(nil), incDist.parameters(nil), 1e-14) {
t.Errorf("nil and uniform weighted prior doesn't match for incremental update for (%d, %d). Uniform weighted is %v, nil is %v", i, j, onesDist, incDist)

MODIFY
stat/distuv/norm.go
stat/distuv/norm.go
@@ -81,7 +81,7 @@ func (Normal) ExKurtosis() float64 {
// are 1. If weights is not nil, then the len(weights) must equal len(samples).
func (n *Normal) Fit(samples, weights []float64) {
suffStat := make([]float64, n.NumSuffStat())
- nSamples := n.SuffStat(samples, weights, suffStat)
+ nSamples := n.SuffStat(suffStat, samples, weights)
n.ConjugateUpdate(suffStat, nSamples, make([]float64, n.NumSuffStat()))
}
@@ -189,7 +189,7 @@ func (n Normal) StdDev() float64 {
//
// If weights is nil, the weights are assumed to be 1, otherwise panics if
// len(samples) != len(weights). Panics if len(suffStat) != NumSuffStat().
-func (Normal) SuffStat(samples, weights, suffStat []float64) (nSamples float64) {
+func (Normal) SuffStat(suffStat, samples, weights []float64) (nSamples float64) {
lenSamp := len(samples)
if len(weights) != 0 && len(samples) != len(weights) {
panic(badLength)

stat/distuv: move destination to first position