Descriptive statistics - extend Ruby Enumerable for common stats methods
Descriptive Statistics is a small gem from Derrick Parkhurst that provides a few common statistics methods to Ruby’s Enumerable:
> require 'descriptive_statistics'
=> true
> data = [2,6,9,3,5,1,8,3,6,9,2]
=> [2, 6, 9, 3, 5, 1, 8, 3, 6, 9, 2]
> data.number
=> 11.0
> data.sum
=> 54
> data.mean
=> 4.909090909090909
> data.median
=> 5.0
> data.variance
=> 7.7190082644628095
> data.standard_deviation
=> 2.778310325442932
> data.percentile(70)
=> 6.0
Browse the source or fork on GitHub.
Update: Francois-Guillaume Ribreau has ported the project to JavaScript as a NPM package.
Update 2: Gleicon Moraes has created a Python port.
Discussion
Sign in or Join to comment or subscribe