Skip to content

Instantly share code, notes, and snippets.

@chezou
Created November 26, 2013 14:26
Show Gist options
  • Save chezou/7659172 to your computer and use it in GitHub Desktop.
Save chezou/7659172 to your computer and use it in GitHub Desktop.
linear regression
require 'narray'
require 'rational'
phi = NMatrix.object(3,4).collect!{ Rational(rand(10)) }
t = NVector.float(4).collect!{ Rational(rand(10)) }
w = (phi.transpose * phi).lu.solve(phi.transpose * t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment