1. ohai
  2. randomext



The library extends class Random in the Ruby standard library.


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


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.


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

require 'randomext'
random_numbers = Array.new(100){ Random::DEFAULT.normal(0.0, 2.0) }


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

I examine numpy to select nice distributions.



Ippei Obayashi ohai@kmc.gr.jp

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.