poly tests!
This commit is contained in:
parent
39e9977724
commit
43212f871f
1 changed files with 35 additions and 0 deletions
35
polynomial_regression_test.go
Normal file
35
polynomial_regression_test.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package chart
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
assert "github.com/blendlabs/go-assert"
|
||||
"github.com/wcharczuk/go-chart/matrix"
|
||||
)
|
||||
|
||||
func TestPolynomialRegression(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
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.GetValue(i)
|
||||
assert.InDelta(float64(i*i), y, matrix.DefaultEpsilon)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue