-
Notifications
You must be signed in to change notification settings - Fork 1
/
myrand.h
executable file
·59 lines (44 loc) · 1.78 KB
/
myrand.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
53
54
55
56
57
58
59
/***************************************************************************
myrand.h - description
-------------------
begin : Aug 24 2001
copyright : (C) 2001 by Tian-Li Yu
email : tianliyu@illigal.ge.uiuc.edu
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef MYRAND_H
#define MYRAND_H
/**
*@author Tian-Li Yu
*/
#include "mt19937ar.h"
class MyRand {
public:
MyRand ();
~MyRand ();
void seed(unsigned long);
bool flip();
bool flip(double prob);
/** From [a,b) */
double uniform(double a, double b);
/** From [0,1) */
double uniform();
/** Standard normal distribution */
double normal();
/** Normal distribution with mean and standard deviation */
double normal(double mean, double std);
/** No descriptions */
int uniformInt(int a, int b);
/** No descriptions */
void uniformArray(int *array, int num, int a, int b);
/** dice according to pr */
int dice(double *pr, int size, double prSum=-1.0);
};
#endif