Skip to content

Latest commit

 

History

History
131 lines (97 loc) · 9.14 KB

README.md

File metadata and controls

131 lines (97 loc) · 9.14 KB

boost_distributions (Ruby gem)

boost_distributions is a Ruby gem to calculate various properties of statistical distributions supported by boost::math::distributions.

Gem Version Ruby

Installation

Install boost headers

Before gem install, boost headers are required. For well-known platforms, try appropriate one of the followings:

Windows Ruby

(Assumption: Most of users may use Ruby installer.) Please check whether your Ruby has been installed with devkit. If not, please re-install Ruby with devkit, which is found at the top of the page. Then, run Start Command Prompt with Ruby from the start menu to launch the command line interface, and type following commands (each line requires hitting enter after inputs, and hit Y key when you are asked something like "install OK?"):

ridk enable
pacman -Syy
pacman -S mingw-w64-ucrt-x86_64-boost

image

Cygwin

By using setup-x86_64.exe Cygwin GUI installer, select libboost-devel unless the headers have been installed. image

UNIX

$ apt-get install libboost-dev

Install gem

After installation of boost headers, install the gem as:

$ gem install boost_distributions

Note that if your boost headers are not in the standard path, the following alternative is helpful for each method.

$ gem install boost_distributions -- --with-boost-include=/path/to/parent_directory_of_boost_header

Or if you want to include it into your application, add this line to Gemfile:

gem 'boost_distributions'

and execute:

$ bundle install

following

$ bundle config build.boost_distributions --with-boost-include=/path/to/parent_directory_of_boost_header

if your boost headers are in the non-standared path.

Usage

Example usage is as the followings:

require 'boost_distributions'

# Generate normal (Gaussian) distribution instance with mu = 0, sigma = 1
normal = BoostDistributions::Normal::new(0, 1)
normal.mean # => 0
normal.standard_deviation # => 1.0

normal.pdf(0) # => 0.399, Probability density function
normal.cdf(0) # => 0.5, Cumulative distribution function
normal.quantile(0.5) # => 0

List of supported distributions are:

Distributions Required minimum boost version
Arcsine Distribution 1.58.0
Bernoulli Distribution 1.35.0
Beta Distribution 1.35.0
Binomial Distribution 1.35.0
Cauchy-Lorentz Distribution 1.35.0
Chi Squared Distribution 1.35.0
Exponential Distribution 1.35.0
Extreme Value Distribution 1.35.0
F Distribution 1.35.0
Gamma (and Erlang) Distribution 1.35.0
Geometric Distribution 1.46.0
Hyperexponential Distribution 1.57.0
Hypergeometric Distribution 1.40.0
Inverse Chi Squared Distribution 1.45.0
Inverse Gamma Distribution 1.45.0
Inverse Gaussian (or Inverse Normal) Distribution 1.46.0
Kolmogorov-Smirnov Distribution 1.75.0
Laplace Distribution 1.40.0
Logistic Distribution 1.40.0
Log Normal Distribution 1.35.0
Negative Binomial Distribution 1.35.0
Noncentral Beta Distribution 1.36.0
Noncentral Chi-Squared Distribution 1.36.0
Noncentral F Distribution 1.36.0
Noncentral T Distribution 1.36.0
Normal (Gaussian) Distribution 1.35.0
Pareto Distribution 1.35.0
Poisson Distribution 1.35.0
Rayleigh Distribution 1.35.0
Skew Normal Distribution 1.50.0
Students t Distribution 1.35.0
Triangular Distribution 1.35.0
Uniform Distribution 1.35.0
Weibull Distribution 1.35.0

See documentation in rubyrdoc.info

Development

After checking out the repo, run bundle install to install dependencies. 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 the created tag, and push the .gem file to rubygems.org.

There are some useful commands in developement life-cycle.

Command Description
bundle exec rake swig Re-generate wrapper C code
bundle exec rake compile compile shared library
bundle exec rake spec run tests

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/fenrir-naru/ruby-boost_distributions. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

Code of Conduct

Everyone interacting in the BoostDistributions project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.