Skip to content

Instantly share code, notes, and snippets.

@oleander
Created January 16, 2013 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oleander/4546544 to your computer and use it in GitHub Desktop.
Save oleander/4546544 to your computer and use it in GitHub Desktop.
xs = %w{1 0 2 0 3 1 0 1 2 0}
ts = %w{16 9 17 12 22 13 8 15 19 11}
y = lambda {|x| 10.2 + 4.0 * x.to_f}
res = xs.each_with_index.map do |x, index|
(ts[index].to_i - y.call(x))**2
end.inject(:+)
puts res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment