Created
January 16, 2013 11:36
-
-
Save oleander/4546544 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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