Skip to content
/ randomext Public

The library extends class Random in the Ruby standard library to efficiently sample random values from various probabilistic distributions

License

Notifications You must be signed in to change notification settings

ohai/randomext

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

randomext

The library extends class Random in the Ruby standard library.

Overview

The Random class in the Ruby standard library supports only random sampling from discrete/continuous uniform distribution.

This library provides random sampling methods from many kinds of probability distributions such as:

  • normal (Gaussian)
  • lognormal
  • Cauthy
  • levy
  • exponential
  • Laplace
  • Rayleigh
  • Weibull
  • Gumbel
  • gamma
  • beta
  • power
  • Chi-square
  • F
  • t
  • Wald (inverse Gaussian)
  • Pareto
  • logistic
  • von Mises
  • Non-Central Chi-Square
  • Non-Central t
  • Planck
  • Bernoulli
  • binomial
  • Poisson
  • geometric
  • negative binomial
  • log series
  • Zipf-Mandelbrot
  • zeta

Usage

To use this library, you need to install randomext gem:

gem install randomext

And write

require 'randomext'

in your ruby script, then you can use some additional methods in Random class.

Example

Create an sequence of random numbers from the Gaussian distribution whose mean is 0.0 and S.D. is 2.0.

require 'randomext'
rng = Random.new  # rng means Random Number Generator
random_numbers = Array.new(100){ rng.normal(0.0, 2.0) }

References

Almost all algorithms are based on: 四辻哲章, "計算機シミュレーションのための確率分布乱数生成法", プレアデス出版 (2010)

I examine numpy to select nice distributions.

URLs

Author

Ippei Obayashi ohai@kmc.gr.jp

Copyright

Copyright (c) 2012, Ippei Obayashi All rights reserved.

The software is licensed under the BSD 2-Clause License. Please see the {file:LICENSE} for more information.

About

The library extends class Random in the Ruby standard library to efficiently sample random values from various probabilistic distributions

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published