Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A Ruby Gem that contains easy to use statistical functions
Ruby
branch: master

This branch is 1 commit ahead, 80 commits behind mgrigajtis:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
.gitignore
Gemfile
README
Rakefile
easystats.gemspec

README

Gem Name: Easystats
Gem Author: Matthew Grigajtis (http://www.matthewgrigajtis.com)
Description: Provides easy to use statistical functions to use on an array 

Functions Provided:
sum
Returns: The sum of the numbers in the array

mean
Returns: The mean (average) of the numbers in the array

average
An alias of mean

standard_deviation
Returns: The standard deviation of the numbers in the array

median
Returns: The median of the numbers in the array

range
Returns: The range of the numbers

mode
Returns: The mode.  If there is no mode returns 0.

variance
Returns: The variance

Example usage:

require "rubygems"
require "easystats"

# Create a test array of numbers
myNumbers = Array.new
myNumbers = [4, 8, 15, 16, 23, 42]

puts "Range: " + myNumbers.range.to_s
puts "Sum: " + myNumbers.sum.to_s
puts "Average: " + myNumbers.mean.to_s
puts "Median: " + myNumbers.median.to_s
puts "Variance: " + myNumbers.variance.to_s
puts "Standard Deviation: " + myNumbers.standard_deviation.to_s
puts "Mode: " + myNumbers.mode.to_s
Something went wrong with that request. Please try again.