Skip to content

Instantly share code, notes, and snippets.

View rikkipitt's full-sized avatar

Rikki Pitt rikkipitt

View GitHub Profile
@rikkipitt
rikkipitt / simple-linear-regression.rb
Last active April 20, 2018 18:47 — forked from rweald/simple-linear-regression.rb
Simple Linear Regression in Ruby
class SimpleLinearRegression
def initialize(xs, ys)
@xs, @ys = xs, ys
if @xs.length != @ys.length
raise "Unbalanced data. xs need to be same length as ys"
end
end
def y_intercept
mean(@ys) - (slope * mean(@xs))