-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRandom.h
52 lines (33 loc) · 1.16 KB
/
Random.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef RANDOM_H
#define RANDOM_H
#include <vector>
double ran2(long *);
double ran_unif(double , double);
// Bernoulli(0,1), p is the probability for success.
inline bool ran_ber(double p) {
return ran_unif(0, 1) <= p;
}
// Integrated uniform random number(n,m)
inline long ran_iunif(long min, long max) {
return (long)ran_unif((double)min, (double)(max+1));
}
// Return specified two numbers a or b
// a indicates the success one with the probability p.
inline long ran_nber(long a, long b, double p) {
return ran_ber(p)? a: b;
}
double ran_norm(double , double );
double ran_exp(double lambda);
double ran_gamma(double , double );
long ran_num(const std::vector<double> &p, const std::vector<long> &num);
unsigned long long ran_num(const std::vector<double> &p,
const std::vector<unsigned long long> &num);
unsigned long long ran_num_log(const std::vector<double> &p, const std::vector<unsigned long long> &num);
double gammaln(double xx);
double gammaf(double xx);
double betaf(double x, double y);
double betad(double x, double a, double b);
double f_fmin(double x, double y);
double f_fmax(double x, double y);
double ran_beta(double aa, double bb);
#endif