go-chart/polynomial_regression_test.go
Zeni Kim cc8d36edd9
Some checks failed
Continuous Integration / Tests (push) Has been cancelled
update url
2024-10-27 21:52:38 -05:00

35 lines
623 B
Go

package chart
import (
"testing"
"git.smarteching.com/zeni/go-chart/v2/matrix"
"git.smarteching.com/zeni/go-chart/v2/testutil"
)
func TestPolynomialRegression(t *testing.T) {
// replaced new assertions helper
var xv []float64
var yv []float64
for i := 0; i < 100; i++ {
xv = append(xv, float64(i))
yv = append(yv, float64(i*i))
}
values := ContinuousSeries{
XValues: xv,
YValues: yv,
}
poly := &PolynomialRegressionSeries{
InnerSeries: values,
Degree: 2,
}
for i := 0; i < 100; i++ {
_, y := poly.GetValues(i)
testutil.AssertInDelta(t, float64(i*i), y, matrix.DefaultEpsilon)
}
}