MCPcopy
hub / github.com/montanaflynn/stats / TestExponentialRegression

Function TestExponentialRegression

regression_test.go:59–94  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

57}
58
59func TestExponentialRegression(t *testing.T) {
60 data := []stats.Coordinate{
61 {1, 2.3},
62 {2, 3.3},
63 {3, 3.7},
64 {4, 4.3},
65 {5, 5.3},
66 }
67
68 r, _ := stats.ExponentialRegression(data)
69 a, _ := stats.Round(r[0].Y, 3)
70 if a != 2.515 {
71 t.Errorf("%v != %v", r[0].Y, 2.515)
72 }
73 a, _ = stats.Round(r[1].Y, 3)
74 if a != 3.032 {
75 t.Errorf("%v != %v", r[1].Y, 3.032)
76 }
77 a, _ = stats.Round(r[2].Y, 3)
78 if a != 3.655 {
79 t.Errorf("%v != %v", r[2].Y, 3.655)
80 }
81 a, _ = stats.Round(r[3].Y, 3)
82 if a != 4.407 {
83 t.Errorf("%v != %v", r[3].Y, 4.407)
84 }
85 a, _ = stats.Round(r[4].Y, 3)
86 if a != 5.313 {
87 t.Errorf("%v != %v", r[4].Y, 5.313)
88 }
89
90 _, err := stats.ExponentialRegression([]stats.Coordinate{})
91 if err == nil {
92 t.Errorf("Empty slice should have returned an error")
93 }
94}
95
96func TestExponentialRegressionYCoordErr(t *testing.T) {
97 c := []stats.Coordinate{{1, -5}, {4, 25}, {6, 5}}

Callers

nothing calls this directly

Calls 2

ExponentialRegressionFunction · 0.92
RoundFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…