Random Number Generation

# Title: Random Number Generation

## 1 GSL::Rng class

### 1.1 Class Method

`GSL::Rng.new([rng_type, seed])`

  This method returns a GSL::Rng object of a random number generator of type rng_type with a seed seed. These two arguments can be omitted, and the generator 'gsl_rng_mt19937' and a seed 0 are used as defaults. GSL provides a number of types of random number generator, one can choose one with a constant GSL::RNG_xxx or a string, as

  - GSL::Rng::MT19937
  - GSL::Rng::RANLXS0
  - GSL::Rng::RANLXS1
  - GSL::Rng::RANLXS2
  - ...
  - "gsl_rng_mt19937", "mt19937"
  - "gsl_rng_tau", "tau"
  - ...

  See GSL manual for the complete list. The following demonstrates how to use this class,

      require 'gsl'

      r = Rng.new(Rng::TAUS, 1)
      r2 = Rng.new(Rng::RAN0, 2)
      p r.get                 <- get an integer
      p r2.uniform            <- get a float of [0, 1)

  A generator of the type gsl_rng_taus is created with seed 1. The method get returns a random integer. The methods uniform returns a floating number uniformly distributed in the range [0, 1).

`GSL::Rng.default_seed`
  Returns the default seed
`GSL::Rng.set_default_seed(seed)`
`GSL::Rng.default_seed=(seed)`
  Override the default seed by seed.
`GSL::Rng.env_setup()`

### 1.2 Instance methods

#### 1.2.1 Generator Initialization

`GSL::Rng#set(s)`
  This method initializes the random number generator with a given seed s.

### 1.3 Sampling from a random number generator

`GSL::Rng#get`
  This returns a random integer from the reciever generator.
`GSL::Rng#uniform`
  This method returns a double precision floating point number uniformly distributed in the range [0,1).
`GSL::Rng#uniform_pos`
  This returns a positive double precision floating point number uniformly distributed in the range (0,1), excluding both 0.0 and 1.0.
`GSL::Rng#uniform_int(n)`
  This method returns a random integer from 0 to n-1 inclusive.

### 1.4 Auxiliary random number generator functions

`GSL::Rng#name`
  This method returns a Sting object of the name of the generator.
`GSL::Rng#max`
`GSL::Rng#min`
  These method return the largest/smallest value that the method get can return.

back