DESCRIPTION

This gem implements random variate generation for several common statistical distributions. Each distribution is implemented in its own class, and different parameterizations are created as instances of the class using the constructor to specify the parameterization. All constructors use named parameters for clarity, so the order of parameters does not matter. All random variate classes provide an optional argument rng, with which the user can specify a U(0,1) generator as an Enumerator to use as the core source of randomness. If rng is not specified, it is based on Ruby's Kernel#rand.

Once a random variate class has been instantiated, values can either be generated on demand using the next method or by using the instance as a generator in any iterable context. Since these are "infinite" generators, enumerative Ruby methods such as .first or .take will require a .each first to yield an iterator for lazy access. Example: my_exp = RV::Exponential.new(rate: 3); my_exp.each.take(50) will yield an array of fifty exponentially distributed values having rate 3.


RELEASE NOTES

v0.4.1

  • Added ability to set rate to new value for Poisson.

v0.4

  • All distribution classes have been placed in a module called RV to try to avoid namespace conflicts.
  • The Gaussian class has been renamed, it is now the Normal class.
  • Parameters for Gaussian and BoxMuller have been renamed. They are now mu: and sigma:.
  • Exponential, Normal, and BoxMuller distribution parameters can now be set to new values without having to instantiate an entirely new generator object.