libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
|
Go to the source code of this file.
Macros | |
#define | GBL_SEED_COUNT |
#define | GBL_RAND_GENERATOR_DEFAULT |
Typedefs | |
typedef int(* | GblRandomGeneratorFn) (void) |
Functions | |
Basic API | |
Basic API for driving random number generation | |
uint64_t | gblSeed (uint8_t index) |
void | gblSeedRand (uint8_t index, uint64_t seed) |
int | gblRand (void) |
void | gblSetRand (GblRandomGeneratorFn pFnGen) |
Generators | |
Builtin random number generators | |
int | gblRandLibC (void) |
int | gblRandLehmer (void) |
Utilities | |
Utility functions for random data generation | |
GblBool | gblRandBool (void) |
void | gblRandBuffer (void *pData, size_t size) |
int | gblRandString (char *pBuffer, int minSize, int maxSize, const char *pCharList) |
Discrete Distributions | |
Random number generation for different discrete distributions | |
int | gblRandBernoulli (float p) |
int | gblRandBinomial (int n, float p) |
int | gblRandEquilikely (int a, int b) |
int | gblRandGeometric (float p) |
int | gblRandPascal (int n, float p) |
int | gblRandPoisson (float m) |
Continuous Distributions | |
Random number generation for different continuous distributions | |
float | gblRandUniform (float a, float b) |
float | gblRandExponential (float m) |
float | gblRandErlang (int n, float b) |
float | gblRandNormal (float m, float s) |
float | gblRandLogNormal (float a, float b) |
float | gblRandChisquare (int n) |
float | gblRandStudent (int n) |
Random number generators and utilities.
This file contains the API and types surrounding random number generation. A series of utilities are provided for generating different types of random output (integer, float, bool, string, etc) as well as a variety of random number distributions.
Definition in file gimbal_random.h.
#define GBL_SEED_COUNT |
Number of different seeds maintained.
Definition at line 30 of file gimbal_random.h.
#define GBL_RAND_GENERATOR_DEFAULT |
Default random number generator backing gblRand()
Definition at line 34 of file gimbal_random.h.
typedef int(* GblRandomGeneratorFn) (void) |
Function prototype for a custom random generator to be set with gblSetRand()
Definition at line 40 of file gimbal_random.h.
uint64_t gblSeed | ( | uint8_t | index | ) |
Returns the seed associated with the given index
.
void gblSeedRand | ( | uint8_t | index, |
uint64_t | seed | ||
) |
Sets the seed associated with the given index
to seed
.
int gblRand | ( | void | ) |
Returns a random number between 0 and RAND_MAX using the current random number generator.
void gblSetRand | ( | GblRandomGeneratorFn | pFnGen | ) |
Sets the current random number generator to pFnGen
, which drives gblRand()
int gblRandLibC | ( | void | ) |
The builtin rand() generator from the C standard library.
int gblRandLehmer | ( | void | ) |
Lehmer linear congruential random number generator.
GblBool gblRandBool | ( | void | ) |
Generates a random boolean value using the current generator.
void gblRandBuffer | ( | void * | pData, |
size_t | size | ||
) |
Fills in the given buffer with random bytes using the current generator.
int gblRandString | ( | char * | pBuffer, |
int | minSize, | ||
int | maxSize, | ||
const char * | pCharList | ||
) |
Fills in buffer with a sized random word (optionally generated using a list of characters)
int gblRandBernoulli | ( | float | p | ) |
Generates a random integer using the current random number generator over a Bernoulli distribution.
int gblRandBinomial | ( | int | n, |
float | p | ||
) |
Generates a random integer using the current random number generator over a Binomial distribution.
int gblRandEquilikely | ( | int | a, |
int | b | ||
) |
Generates a random integer using the current random number generator over the given range [a, b].
int gblRandGeometric | ( | float | p | ) |
Generates a random integer using the current random number generator over a Geometric distribution.
int gblRandPascal | ( | int | n, |
float | p | ||
) |
Generates a random integer using the current random number generator over a Pascal distribution.
int gblRandPoisson | ( | float | m | ) |
Generates a random integer using the current random number generator over a Poisson distribution.
float gblRandUniform | ( | float | a, |
float | b | ||
) |
Generates a random float using the current random number generator over the given range [a, b].
float gblRandExponential | ( | float | m | ) |
Generates a random float using the current random number generator over an Exponential distribution.
float gblRandErlang | ( | int | n, |
float | b | ||
) |
Generates a random float using the current random number generator over an Erlang distribution.
float gblRandNormal | ( | float | m, |
float | s | ||
) |
Generates a random integer using the current random number generator over a Normal distribution.
float gblRandLogNormal | ( | float | a, |
float | b | ||
) |
Generates a random integer using the current random number generator over a Log Normal distribution.
float gblRandChisquare | ( | int | n | ) |
Generates a random integer using the current random number generator over a Chisquare distribution.
float gblRandStudent | ( | int | n | ) |
Generates a random integer using the current random number generator over a Student distribution.