naev 0.11.5
rng.h
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
4#pragma once
5
11#define RNG(L,H) (((L)>(H)) ? RNG_BASE((H),(L)) : RNG_BASE((L),(H))) /* L <= RNG <= H */
17#define RNG_BASE(L,H) ((int)L + (int)((double)(H-L+1) * randfp())) /* L <= RNG <= H */
21#define RNGF() (randfp()) /* 0. <= RNGF <= 1. */
27#define RNG_1SIGMA() NormalInverse(0.158655255 + RNGF()*(1.-0.158655255*2.))
33#define RNG_2SIGMA() NormalInverse(0.022750132 + RNGF()*(1.-0.022750132*2.))
39#define RNG_3SIGMA() NormalInverse(0.0013498985 + RNGF()*(1.-0.0013498985*2.))
40
41/* Init */
42void rng_init (void);
43
44/* Random functions */
45unsigned int randint (void);
46double randfp (void);
47
48/* Probability functions */
49double Normal( double x );
50double NormalInverse( double p );
double Normal(double x)
Calculates the Normal distribution.
Definition rng.c:203
double randfp(void)
Gets a random float between 0 and 1 (inclusive).
Definition rng.c:180
double NormalInverse(double p)
Calculates the inverse of the normal.
Definition rng.c:282
void rng_init(void)
Initializes the random subsystem.
Definition rng.c:56
unsigned int randint(void)
Gets a random integer.
Definition rng.c:167