Skip to content

Instantly share code, notes, and snippets.

@omphalos
Created August 17, 2013 16:52
Show Gist options
  • Save omphalos/6257772 to your computer and use it in GitHub Desktop.
Save omphalos/6257772 to your computer and use it in GitHub Desktop.
multiple regression with sylvester
var sylvester = require('sylvester')
function multipleRegression(x, y) {
var X = $M(x)
, Y = $M(y)
, Xt = X.transpose()
, regression = Xt.multiply(X).inverse().multiply(Xt).multiply(Y)
return regression
}
var x = [
[8,3,9],
[2,0,7],
[1,9,3]
]
var y = [[10,1], [21,2], [31,3]]
console.log('result', multipleRegression(x, y))
@omphalos
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment