Debian Codegraph @

polynomial_regression_test.go

raw symbols SCIP
1 package chart
2
3 import (
4 "testing"
5
6 "github.com/wcharczuk/go-chart/v2/matrix"
7 "github.com/wcharczuk/go-chart/v2/testutil"
8 )
9
10 func TestPolynomialRegression(t *testing.T) {
11 // replaced new assertions helper
12
13 var xv []float64
14 var yv []float64
15
16 for i := 0; i < 100; i++ {
17 xv = append(xv, float64(i))
18 yv = append(yv, float64(i*i))
19 }
20
21 values := ContinuousSeries{
22 XValues: xv,
23 YValues: yv,
24 }
25
26 poly := &PolynomialRegressionSeries{
27 InnerSeries: values,
28 Degree: 2,
29 }
30
31 for i := 0; i < 100; i++ {
32 _, y := poly.GetValues(i)
33 testutil.AssertInDelta(t, float64(i*i), y, matrix.DefaultEpsilon)
34 }
35 }