2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#ifndef GIMBAL_RANDOM_H
26#define GIMBAL_RANDOM_H
28#include "../core/gimbal_decls.h"
30#define GBL_SEED_COUNT 2
32#ifndef GBL_RAND_GENERATOR_DEFAULT
34# define GBL_RAND_GENERATOR_DEFAULT gblRandLehmer
43
44
45
48
49
50
62
63
64
72
73
74
87
88
89
105
106
107
127#define gblRandString(...)
128 gblRandStringDefault_
(__VA_ARGS__)
129#define gblRandStringDefault_(...)
130 gblRandStringDefault__
(__VA_ARGS__, GBL_NULL)
131#define gblRandStringDefault__(buffer, min, max, chars, ...)
132 (gblRandString
)(buffer, min, max, chars)
int gblRandPascal(int n, float p)
Generates a random integer using the current random number generator over a Pascal distribution.
float gblRandChisquare(int n)
Generates a random integer using the current random number generator over a Chisquare distribution.
float gblRandErlang(int n, float b)
Generates a random float using the current random number generator over an Erlang distribution.
int gblRandPoisson(float m)
Generates a random integer using the current random number generator over a Poisson distribution.
float gblRandLogNormal(float a, float b)
Generates a random integer using the current random number generator over a Log Normal distribution.
int gblRandLehmer(void)
Lehmer linear congruential random number 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)
void gblRandBuffer(void *pData, size_t size)
Fills in the given buffer with random bytes using the current generator.
int gblRandEquilikely(int a, int b)
Generates a random integer using the current random number generator over the given range [a,...
uint64_t gblSeed(uint8_t index)
Returns the seed associated with the given index.
float gblRandExponential(float m)
Generates a random float using the current random number generator over an Exponential distribution.
void gblSetRand(GblRandomGeneratorFn pFnGen)
Sets the current random number generator to pFnGen, which drives gblRand()
int gblRandGeometric(float p)
Generates a random integer using the current random number generator over a Geometric distribution.
void gblSeedRand(uint8_t index, uint64_t seed)
Sets the seed associated with the given index to seed.
int gblRandLibC(void)
The builtin rand() generator from the C standard library.
int gblRandBinomial(int n, float p)
Generates a random integer using the current random number generator over a Binomial distribution.
int gblRand(void)
Returns a random number between 0 and RAND_MAX using the current random number generator.
float gblRandStudent(int n)
Generates a random integer using the current random number generator over a Student distribution.
float gblRandUniform(float a, float b)
Generates a random float using the current random number generator over the given range [a,...
int(* GblRandomGeneratorFn)(void)
Function prototype for a custom random generator to be set with gblSetRand()
float gblRandNormal(float m, float s)
Generates a random integer using the current random number generator over a Normal distribution.
GblBool gblRandBool(void)
Generates a random boolean value using the current generator.
int gblRandBernoulli(float p)
Generates a random integer using the current random number generator over a Bernoulli distribution.
uint8_t GblBool
Basic boolean type, standardized to sizeof(char)