Skip to content

Instantly share code, notes, and snippets.

@mufid
Created May 7, 2015 01:20
Show Gist options
  • Save mufid/c92b876d28437400597a to your computer and use it in GitHub Desktop.
Save mufid/c92b876d28437400597a to your computer and use it in GitHub Desktop.
ruby-descriptive-statistics-sample.rb
#!/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