samer@0: #include samer@0: #include "RngStream.h" samer@0: samer@0: // random generator state samer@0: typedef struct { samer@0: struct rng_state g; samer@0: double prev_normal; samer@0: } RndState; samer@0: samer@0: typedef struct { samer@0: struct rng_jump j; samer@0: int e; samer@0: } RndJump; samer@0: samer@0: int randomise_from(FILE *p, RndState *S); samer@0: int spawn_gen(RndState *S0, RndState *S1); samer@0: void InitRndState(RndState *S); samer@0: samer@0: double Raw(RndState *); samer@0: double Uniform(RndState *); samer@0: double Normal(RndState *); samer@0: double Exponential(RndState *); samer@0: double Gamma(RndState *,double a); samer@0: long Poisson(RndState *,double a); samer@0: int Dirichlet(RndState *,long n, double *a, double *x); samer@0: double Beta(RndState *,double a, double b); samer@0: double Zeta(RndState *,double a); samer@0: int Binomial(RndState *,double p, int n); samer@0: double Stable(RndState *,int param,double a, double b); samer@0: long Discrete(RndState *, long n, double *p, double tot); samer@0: