by cheald · 14y ago · 0 comments
require 'gsl'
x = GSL::Vector.alloc(array_of_x_values)
y = GSL::Vector.alloc(array_of_y_values)
c0, c1, cov00, cov01, cov11, chisq, status = GSL::Fit::linear(x, y)
It's not nearly as much work, and it's much faster than doing it in pure Ruby. :)(It also does weighted regressions and exponential fitting, among a host of other things. That wheel's gone done been invented already.)
GSL can be used internally ("in-house") without restriction, but only redistributed in other software that is under the GNU GPL.
http://www.gnu.org/software/gsl/Thanks for pointing out GSL. I appreciate the feedback.
It's great to see other people doing statistical work in Ruby, though, so please don't let my criticism keep you from continuing to do it! :)
While we do some stats in Ruby it definitely doesn't represent the entire "this is how we solved it". In fact we use a large amount of R and Java to solve all our statistics problems.