Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ruby_native_statistics

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ruby_native_statistics

  • 1.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Ruby Native Statistics

Test status

This is a native extension to Ruby that adds native (C) statistical functions to the Array class. At present the following functions are provided:

Check the Github Actions build to see the currently supported versions of Ruby. This list will match whatever stable versions are specified at https://www.ruby-lang.org/en/downloads/.

It is generally more performant than calculating these values with pure Ruby. For a comparison, run the benchmarks with rake benchmark.

Test (Ruby 3.3.0)Run 1Run 2Run 3Run 4Run 5
bench_native_stdev0.0000690.0000740.0000640.0000650.000065
bench_ruby_stdev0.0009470.0009320.0009270.0009480.000909
Test (Ruby 3.3.0)Run 1Run 2Run 3Run 4Run 5
bench_native_median0.0007190.000670.0006590.0006380.000668
bench_ruby_median0.0007740.0007430.0007240.0006970.000683
Test (Ruby 3.3.0)Run 1Run 2Run 3Run 4Run 5
bench_native_mean0.0000350.0000350.0000340.0000320.000033
bench_ruby_mean0.0002910.0002870.0002910.0002990.000281

Found a bug? Need a function?

If you found a bug or need a particular function, please let me know! I work on this gem in my spare time, mainly for learning purposes. Feel free to open a PR or a Github issue and I'll take a look as soon as possible.

Usage

require 'ruby_native_statistics'
r = [1,3,21,32,42]

# calculate sample standard deviation, you can also use "stdevs"
p r.stdev

# calculate population standard deviation
p r.stdevp

# calculate mean
p r.mean

# calculate median
p r.median

# calculate percentile
p r.percentile(0.3333)

Implementation notes

Percentile

Percentile uses the same rounding method as Excel, sometimes called R7.

This is the third version of this gem, and it is a total rewrite of a SWIG-based design. Lots of thanks to the following resources:

FAQs

Package last updated on 03 Mar 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc