Wrapper routines for GSL random number functions.
More...
Defines |
#define | PMC_RAND_GSL_SUCCESS 0 |
| Result code indicating successful completion.
|
#define | PMC_RAND_GSL_INIT_FAIL 1 |
| Result code indicating initialization failure.
|
#define | PMC_RAND_GSL_NOT_INIT 2 |
| Result code indicating the generator was not initialized when it should have been.
|
#define | PMC_RAND_GSL_ALREADY_INIT 3 |
| Result code indicating the generator was already initialized when an initialization was attempted.
|
Functions/Subroutines |
int | pmc_srand_gsl (int seed) |
| Initialize the random number generator with the given seed.
|
int | pmc_rand_finalize_gsl () |
| Cleanup and deallocate the random number generator.
|
int | pmc_rand_gsl (double *harvest) |
| Generate a uniform random number in .
|
int | pmc_rand_int_gsl (int n, int *harvest) |
| Generate a uniform random integer in .
|
int | pmc_rand_normal_gsl (double mean, double stddev, double *harvest) |
| Generate a normally-distributed random number.
|
int | pmc_rand_poisson_gsl (double mean, int *harvest) |
| Generate a Poisson-distributed random integer.
|
int | pmc_rand_binomial_gsl (int n, double p, int *harvest) |
| Generate a Binomial-distributed random integer.
|
Variables |
static gsl_rng * | pmc_rand_gsl_rng = NULL |
| Private internal-use variable to store the random number generator.
|
Detailed Description
Wrapper routines for GSL random number functions.
Define Documentation
#define PMC_RAND_GSL_ALREADY_INIT 3 |
Result code indicating the generator was already initialized when an initialization was attempted.
#define PMC_RAND_GSL_INIT_FAIL 1 |
Result code indicating initialization failure.
#define PMC_RAND_GSL_NOT_INIT 2 |
Result code indicating the generator was not initialized when it should have been.
#define PMC_RAND_GSL_SUCCESS 0 |
Result code indicating successful completion.
Function Documentation
int pmc_rand_binomial_gsl |
( |
int |
n, |
|
|
double |
p, |
|
|
int * |
harvest |
|
) |
| |
Generate a Binomial-distributed random integer.
- Parameters:
-
n | The sample size for the distribution. |
p | The sample probability for the distribution. |
harvest | A pointer to the generated random number. |
- Returns:
- PMC_RAND_GSL_SUCCESS on success, otherwise an error code.
int pmc_rand_finalize_gsl |
( |
) |
|
Cleanup and deallocate the random number generator.
This must be called after pmc_srand_gsl().
- Returns:
- PMC_RAND_GSL_SUCCESS on success, otherwise an error code.
int pmc_rand_gsl |
( |
double * |
harvest ) |
|
Generate a uniform random number in
.
- Parameters:
-
harvest | A pointer to the generated random number. |
- Returns:
- PMC_RAND_GSL_SUCCESS on success, otherwise an error code.
int pmc_rand_int_gsl |
( |
int |
n, |
|
|
int * |
harvest |
|
) |
| |
Generate a uniform random integer in
.
- Parameters:
-
n | The upper limit of the random integer. |
harvest | A pointer to the generated random number. |
- Returns:
- PMC_RAND_GSL_SUCCESS on success, otherwise an error code.
int pmc_rand_normal_gsl |
( |
double |
mean, |
|
|
double |
stddev, |
|
|
double * |
harvest |
|
) |
| |
Generate a normally-distributed random number.
- Parameters:
-
mean | The mean of the distribution. |
stddev | The standard deviation of the distribution. |
harvest | A pointer to the generated random number. |
- Returns:
- PMC_RAND_GSL_SUCCESS on success, otherwise an error code.
int pmc_rand_poisson_gsl |
( |
double |
mean, |
|
|
int * |
harvest |
|
) |
| |
Generate a Poisson-distributed random integer.
- Parameters:
-
mean | The mean of the distribution. |
harvest | A pointer to the generated random number. |
- Returns:
- PMC_RAND_GSL_SUCCESS on success, otherwise an error code.
int pmc_srand_gsl |
( |
int |
seed ) |
|
Initialize the random number generator with the given seed.
This must be called before any other GSL random number functions are called.
- Parameters:
-
seed | The random seed to use. |
- Returns:
- PMC_RAND_GSL_SUCCESS on success, otherwise an error code.
- See also:
- pmc_rand_finalize_gsl() to cleanup the generator.
Variable Documentation
Private internal-use variable to store the random number generator.