libspatialSEIR  0.1
Bayesian Spatial SEIR Modeling
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
RandomNumberProvider.hpp
Go to the documentation of this file.
1 #ifndef SPATIALSEIR_INCLUDEFILES
2 #define SPATIALSEIR_INCLUDEFILES
3 
4 #include<math.h>
5 #include<cstring>
6 #include<vector>
7 #endif
8 
9 #ifndef RANDOM_NUMBER_PROVIDER_INC
10 #define RANDOM_NUMBER_PROVIDER_INC
11 
12 
13 #ifdef LSS_USE_BOOST
14 
15 #include<boost/random/mersenne_twister.hpp>
16 #include<boost/random/uniform_real.hpp>
17 #include<boost/random/uniform_int_distribution.hpp>
18 #include<boost/random/gamma_distribution.hpp>
19 #include<boost/random/poisson_distribution.hpp>
20 #include<boost/random/normal_distribution.hpp>
21 #include<boost/random/binomial_distribution.hpp>
22 #include <boost/math/distributions/normal.hpp>
23 
24 
25 
26 namespace SpatialSEIR
27 {
28  class RandomNumberProvider
29  {
30  boost::random::mt19937 generator;
31  boost::random::uniform_real_distribution<> unidist;
32  boost::random::uniform_int_distribution<> unidist_int;
33  boost::random::gamma_distribution<> gammadist;
34  public:
35  //Random Methods
36  RandomNumberProvider(unsigned int seed);
37  double uniform();
38  int uniform_int();
39  int uniform_int(int a, int b);
40  int poisson(int mu);
41  double normal(double mu, double sd);
42  double* uniform(int n);
43  double* uniform(int n, double* output);
44  double gamma();
45  double gamma(double a);
46  double* gamma(int n);
47  double* gamma(int n, double* output);
48  double beta(double a, double b);
49  int binom(int n, double p);
50 
51 
52  //Density Functions
53  double dpois(int x, double mu);
54  double dnorm(double x, double mu, double sd);
55  double dbinom(int x, int n, double p);
56  double dgamma(double x, double a, double b);
57 
58  // Utility Functions
59  double choose(int n,int k);
60  double choosePartial(int n,int k);
61 
62  double factorial(int k);
63 
64  //Data
65  double* logFactorialMemo;
66  int* maxFactorial;
67 
69  };
70 }
71 #endif
72 #ifndef LSS_USE_BOOST
73 
74 #include<Rcpp.h>
75 
76 namespace SpatialSEIR
77 {
79  {
80  public:
81  //Random Methods
82  RandomNumberProvider(unsigned int seed);
83  double uniform();
84  int uniform_int();
85  int uniform_int(int a, int b);
86  int poisson(int mu);
87  double normal(double mu, double sd);
88  double* uniform(int n);
89  double* uniform(int n, double* output);
90  double gamma();
91  double gamma(double a);
92  double* gamma(int n);
93  double* gamma(int n, double* output);
94  double beta(double a, double b);
95  int binom(int n, double p);
96 
97  //Density Functions
98  double dpois(int x, double mu);
99  double dnorm(double x, double mu, double sd);
100  double dbinom(int x, int n, double p);
101  double dgamma(double x, double a, double b);
102 
104  };
105 }
106 
107 
108 #endif
109 #endif
int uniform_int()
Definition: RandomNumberProvider.cpp:224
double uniform()
Definition: RandomNumberProvider.cpp:220
double normal(double mu, double sd)
Definition: RandomNumberProvider.cpp:236
double dpois(int x, double mu)
Definition: RandomNumberProvider.cpp:244
double dbinom(int x, int n, double p)
Definition: RandomNumberProvider.cpp:248
double gamma()
Definition: RandomNumberProvider.cpp:268
int poisson(int mu)
Definition: RandomNumberProvider.cpp:232
double dgamma(double x, double a, double b)
Definition: RandomNumberProvider.cpp:252
RandomNumberProvider(unsigned int seed)
Definition: RandomNumberProvider.cpp:216
double beta(double a, double b)
Definition: RandomNumberProvider.cpp:294
Definition: RandomNumberProvider.hpp:78
~RandomNumberProvider()
Definition: RandomNumberProvider.cpp:298
int binom(int n, double p)
Definition: RandomNumberProvider.cpp:277
double dnorm(double x, double mu, double sd)
Definition: RandomNumberProvider.cpp:240