Adds matrix sub package & adds polynomial regression series (#36)

* updates

* updates

* tests.

* test coverage

* fixing test

* stride not rows + cols

* lu decomp implementation.

* poly regression!

* poly regression works.

* typo.
This commit is contained in:
Will Charczuk 2017-04-18 20:20:29 -07:00 committed by GitHub
parent b3dc3fef3c
commit a211e88530
10 changed files with 1292 additions and 9 deletions

22
matrix/regression_test.go Normal file
View file

@ -0,0 +1,22 @@
package matrix
import (
"testing"
assert "github.com/blendlabs/go-assert"
)
func TestPoly(t *testing.T) {
assert := assert.New(t)
var xGiven = []float64{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
var yGiven = []float64{1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321}
var degree = 2
c, err := Poly(xGiven, yGiven, degree)
assert.Nil(err)
assert.Len(c, 3)
assert.InDelta(c[0], 0.999999999, DefaultEpsilon)
assert.InDelta(c[1], 2, DefaultEpsilon)
assert.InDelta(c[2], 3, DefaultEpsilon)
}