NcmRNG

NcmRNG — Encapsulated GSL random number generator with support for multhreading.

Properties

gchar * algorithm Read / Write / Construct
gulong seed Read / Write
gchar * state Read / Write

Object Hierarchy

    GObject
    ╰── NcmRNG

Description

This object encapsulates the GSL pseudo random number generator (PRNG). The purpose is to add support for saving and loading state and multhreading.

Functions

ncm_rng_new ()

NcmRNG *
ncm_rng_new (const gchar *algo);

Creates a new NcmRNG using the algorithm algo see the list of algorithms here ( http://www.gnu.org/software/gsl/manual/html_node/Random-number-generator-algorithms.html ). If algo is NULL the default algorithm and seed are used, see ( http://www.gnu.org/software/gsl/manual/html_node/Random-number-environment-variables.html#Random-number-environment-variables ) for more details.

Parameters

algo

algorithm name.

[allow-none]

Returns

a new NcmRNG.

[transfer full]


ncm_rng_seeded_new ()

NcmRNG *
ncm_rng_seeded_new (const gchar *algo,
                    gulong seed);

Creates a new NcmRNG using the algorithm algo see the list of algorithms here ( http://www.gnu.org/software/gsl/manual/html_node/Random-number-generator-algorithms.html ). If algo is NULL the default algorithm is used, see ( http://www.gnu.org/software/gsl/manual/html_node/Random-number-environment-variables.html#Random-number-environment-variables ) for more details.

Parameters

algo

algorithm name.

[allow-none]

seed

seed used to initialize the PRNG.

 

Returns

a new NcmRNG.

[transfer full]


ncm_rng_ref ()

NcmRNG *
ncm_rng_ref (NcmRNG *rng);

Increases the reference count of rng by one.

Parameters

rng

a NcmRNG.

 

Returns

rng .

[transfer full]


ncm_rng_free ()

void
ncm_rng_free (NcmRNG *rng);

Decreases the reference count of rng by one.

Parameters

rng

a NcmRNG.

 

ncm_rng_clear ()

void
ncm_rng_clear (NcmRNG **rng);

Decreases the reference count of *rng by one and sets *rng to NULL.

Parameters

rng

a NcmRNG.

 

ncm_rng_lock ()

void
ncm_rng_lock (NcmRNG *rng);

Locks rng .

Parameters

rng

a NcmRNG.

 

ncm_rng_unlock ()

void
ncm_rng_unlock (NcmRNG *rng);

Unlocks rng .

Parameters

rng

a NcmRNG.

 

ncm_rng_get_algo ()

const gchar *
ncm_rng_get_algo (NcmRNG *rng);

Gets the name of the algorithm.

Parameters

rng

a NcmRNG.

 

Returns

algorithm name.

[transfer none]


ncm_rng_get_state ()

gchar *
ncm_rng_get_state (NcmRNG *rng);

Gets the state of the algorithm in Base64. It can be a very large string depending on the underlining

Parameters

rng

a NcmRNG.

 

Returns

algorithm state.

[transfer full]


ncm_rng_set_algo ()

void
ncm_rng_set_algo (NcmRNG *rng,
                  const gchar *algo);

Sets the algorithm.

Parameters

rng

a NcmRNG.

 

algo

algorithm name.

 

ncm_rng_set_state ()

void
ncm_rng_set_state (NcmRNG *rng,
                   const gchar *state);

Sets the algorithm state.

Parameters

rng

a NcmRNG.

 

state

algorithm state.

 

ncm_rng_check_seed ()

gboolean
ncm_rng_check_seed (NcmRNG *rng,
                    gulong seed);

Check if the seed was already used by any NcmRNG.

Parameters

rng

a NcmRNG.

 

seed

seed for the PRNG.

 

Returns

TRUE is seed was never used.


ncm_rng_set_seed ()

void
ncm_rng_set_seed (NcmRNG *rng,
                  gulong seed);

Sets the algorithm seed.

Parameters

rng

a NcmRNG.

 

seed

seed for the PRNG.

 

ncm_rng_get_seed ()

gulong
ncm_rng_get_seed (NcmRNG *rng);

Parameters

rng

a NcmRNG.

 

Returns

the seed used to initialize the PRNG.


ncm_rng_set_random_seed ()

void
ncm_rng_set_random_seed (NcmRNG *rng,
                         gboolean allow_colisions);

Sets the algorithm seed using a PRNG seeded by /dev/urandom (Unix/Linux) or current time when the first is not available (see g_rand_new()). If allow_colisions is FALSE this function will set the first unused seed generated.

Parameters

rng

a NcmRNG.

 

allow_colisions

a gboolean.

 

ncm_rng_pool_get ()

NcmRNG *
ncm_rng_pool_get (const gchar *name);

Gets the NcmRNG named name from the pool. If it doesn't exists creates one, add to the pool and returns it.

Parameters

name

a string.

 

Returns

the NcmRNG named name .

[transfer full]


ncm_rng_uniform_gen ()

gdouble
ncm_rng_uniform_gen (NcmRNG *rng,
                     const gdouble xl,
                     const gdouble xu);

FIXME

Parameters

rng

a NcmRNG

 

xl

FIXME

 

xu

FIXME

 

ncm_rng_gaussian_gen ()

gdouble
ncm_rng_gaussian_gen (NcmRNG *rng,
                      const gdouble mu,
                      const gdouble sigma);

FIXME

Parameters

rng

a NcmRNG

 

mu

FIXME

 

sigma

FIXME

 

ncm_rng_ugaussian_gen ()

gdouble
ncm_rng_ugaussian_gen (NcmRNG *rng);

ncm_rng_gaussian_tail_gen ()

gdouble
ncm_rng_gaussian_tail_gen (NcmRNG *rng,
                           const gdouble a,
                           const gdouble sigma);

FIXME

Parameters

rng

a NcmRNG

 

a

FIXME

 

sigma

FIXME

 

ncm_rng_exponential_gen ()

gdouble
ncm_rng_exponential_gen (NcmRNG *rng,
                         const gdouble mu);

FIXME

Parameters

rng

a NcmRNG

 

mu

FIXME

 

ncm_rng_laplace_gen ()

gdouble
ncm_rng_laplace_gen (NcmRNG *rng,
                     const gdouble a);

FIXME

Parameters

rng

a NcmRNG

 

a

FIXME

 

ncm_rng_exppow_gen ()

gdouble
ncm_rng_exppow_gen (NcmRNG *rng,
                    const gdouble a,
                    const gdouble b);

FIXME

Parameters

rng

a NcmRNG

 

a

FIXME

 

b

FIXME

 

ncm_rng_beta_gen ()

gdouble
ncm_rng_beta_gen (NcmRNG *rng,
                  const gdouble a,
                  const gdouble b);

FIXME

Parameters

rng

a NcmRNG

 

a

FIXME

 

b

FIXME

 

ncm_rng_gamma_gen ()

gdouble
ncm_rng_gamma_gen (NcmRNG *rng,
                   const gdouble a,
                   const gdouble b);

FIXME

Parameters

rng

a NcmRNG

 

a

FIXME

 

b

FIXME

 

Types and Values

Property Details

The “algorithm” property

  “algorithm”                gchar *

Algorithm name.

Flags: Read / Write / Construct

Default value: "mt19937"


The “seed” property

  “seed”                     gulong

Algorithm seed.

Flags: Read / Write


The “state” property

  “state”                    gchar *

Algorithm state.

Flags: Read / Write

Default value: NULL