rng_alloc(type)
rng_clone(r)
rng_name(r)
rng_max(r)
rng_min(r)
rng_set(r, seed)
rng_get(r, length)
rng_uniform(r, length)
rng_uniform_int(r, N, length)
rng_uniform_pos(r, length)
rng_alloc()
, type of random number generator.
This argument is taken to be a character string which is matched to
the names of the random number generators given in the GSL manual
section 17.9, with the initial gsl_rng_
removed
(for example, to use generator gsl_rng_ranlux
, set
type
to ranlux
). Partial matching is used; a null
string is interpreted as mt19937
.rng_alloc()
.rng_uniform_int()
, upper bound of
uniform distributionrng_alloc()
returns an external pointer to a GSL random
number generator.
rng_free
is not necessary as R performs garbage
collection automatically.The functions that return random numbers (rng_get
,
rng_uniform
, rng_uniform_int
, rng_uniform_pos
)
take an extra argument that specifies the length of the vector of
random numbers to be returned.
r <- rng_alloc("cmrg")
rng_set(r, 100)
rng_uniform(r, 10)
Run the code above in your browser using DataLab