Gem Version Build Status

Lite::Statistics is a library for generate statistics from collections of data points.


Add this line to your application's Gemfile:

gem 'lite-statistics'

And then execute:

$ bundle

Or install it yourself as:

$ gem install lite-statistics

Table of Contents


rails g lite:statistics:install will generate the following file: ../config/initalizers/lite_statistics.rb

Lite::Statistics.configure do |config|
  config.monkey_patches = true


Sample|Population calculations will have a shorthand alias that defaults to sample.

Ex: variance => sample_variance




Central tendency




Monkey patches

Including monkey patches will give you Enumerable access to statistics.

[1, 2, 3, 1].mode #=> 1


All benchmarks are executed using the baseline summary (exact same calculations for each) and the full summary (all available calculations for each). Each is generated using an array containing 1 million random integers on the 2.6.3 Ruby version.

View how each compares to other libs by running the benchmarks.

Baseline summaries

Library # of Calculations IPS Speed
lite-statistics 13 2.5 i/s ---
descriptive_statistics 13 0.6 i/s 4.16x slower
descriptive-statistics 13 1.8 i/s 1.40x slower
statistica 13 --- Too slow to run

Full summaries

Library # of Calculations IPS Speed
lite-statistics 22 1.0 i/s ---
descriptive_statistics 13 0.6 i/s 1.72x slower
descriptive-statistics 16 0.9 i/s 1.10x slower
statistica 19 --- Too slow to run


After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to


Bug reports and pull requests are welcome on GitHub at[USERNAME]/lite-statistics. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.


The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Lite::Statistics project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.