Created
September 25, 2009 21:46
-
-
Save reinh/193872 to your computer and use it in GitHub Desktop.
This file contains 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
# Compute an average for <back> elements from the end of the results | |
def average_value(back, results) | |
return results['values'].last['value'] if back.zero? | |
values = results['values'].map { |item| item['value'] } | |
average[-back, back].inject {|sum, i| sum + i} / range_of_interest.size.to_f | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment