
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
descriptive-statistics
Advanced tools
This gem calculates descriptive statistics including measures of central tendency (e.g. mean, median mode), dispersion (e.g. range, and quartiles), and spread (e.g variance and standard deviation).
Tested against ruby 1.8.7, 1.9.2, 1.9.3, 2.0.0, 2.1.0, ruby-head, jruby-18mode, jruby-19mode, jruby-head, rbx-2.1.1, rbx-2.2.0, rbx-2.2.1 and ree
Add this line to your application's Gemfile:
gem 'descriptive-statistics'
And then execute:
$ bundle
Or install it yourself as:
$ gem install descriptive-statistics
stats = DescriptiveStatistics::Stats.new([1,1,2,3,10])
stats.mean #=> 3.4
stats.median #=> 2
stats.mode #=> 1
stats = DescriptiveStatistics::Stats.new([1,1,2,3,10])
stats.range #=> 9
stats.min #=> 1
stats.max #=> 10
stats.percentile_from_value(10) #=> 80
stats.value_from_percentile(60) #=> 3
stats = DescriptiveStatistics::Stats.new([1,1,2,3,10])
stats.variance #=> 14.299999999999999
stats.population_variance #=> 11.44
stats.standard_deviation #=> 3.7815340802378072
stats.relative_standard_deviation #=> 99.47961485463391
stats = DescriptiveStatistics::Stats.new([1,1,2,3,10])
stats.skewness #=> 1.188328915820243
stats.kurtosis #=> 2.405613966453127
If you want to monkey patch descriptive statistics methods into Enumerable, you can use the following:
(e.g. config/initializers/descriptive_statistics_monkey_patch.rb)
require 'descriptive-statistics'
module Enumerable
include DescriptiveStatistics
# Warning: hacky evil meta programming. Required because classes that have already included
# Enumerable will not otherwise inherit the statistics methods.
DescriptiveStatistics.instance_methods.each do |m|
define_method(m, DescriptiveStatistics.instance_method(m))
end
end
Then you can use these methods directly on Arrays:
[1,1,2,3,10].mean #=> 3.4
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that descriptive-statistics demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.