Skip to content

Commit 033754a

Browse files
committed
fit: fix polynomial regression for d >= 4
This stumbled over the classic capturing-the-loop-variable bug so all terms from degree 3 and on used the highest degree.
1 parent 03302a9 commit 033754a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fit/lsquares.go

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ func PolynomialRegression(xs, ys, weights []float64, degree int) PolynomialRegre
152152
}
153153
}
154154
for d := 3; d < len(terms); d++ {
155+
d := d
155156
terms[d] = func(xs, termOut []float64) {
156157
for i, x := range xs {
157158
termOut[i] = math.Pow(x, float64(d+1))

0 commit comments

Comments
 (0)