Created
May 7, 2015 01:20
-
-
Save mufid/c92b876d28437400597a to your computer and use it in GitHub Desktop.
ruby-descriptive-statistics-sample.rb
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
#!/usr/bin/env ruby | |
require "rubygems" | |
require 'descriptive_statistics' | |
arr = [] | |
ARGF.each_with_index do |line, idx| | |
# print ARGF.filename, ":", idx, ";", line | |
arr << line.to_i if line.to_i > 0 | |
end | |
puts "Statistics" | |
puts " Minimum: #{arr.min}" | |
puts " Maximum: #{arr.max}" | |
puts " Mean: #{arr.mean}" | |
puts " Standard Deviation: #{arr.standard_deviation}" | |
puts " Percentile 25: #{arr.percentile 25}" | |
puts " Percentile 75: #{arr.percentile 75}" | |
puts " Percentile 90: #{arr.percentile 90}" | |
puts " Percentile 95: #{arr.percentile 95}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment