randomext 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/binomial.c +24 -40
- data/ext/hypergeometric.c +3 -3
- data/ext/other.c +8 -8
- data/ext/poisson.c +1 -1
- data/ext/standard_normal.c +1 -31
- data/ext/standard_normal_table.h +392 -0
- metadata +19 -18
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5b23ad8095b3b5d4a95d99892b179002f3f639a7
|
4
|
+
data.tar.gz: b28e03eb8da6adb9325c0907110c323ba58b94c9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5a3e55f905a6a9d9161a4991a88b6d1775fe10677373bb69cfacccfd4b1cf1b92def5e247a8212e03e6ade47364f5b4f4fa91e78eab94faafb55b0accbaa2fd2
|
7
|
+
data.tar.gz: ea89f943c1b2d18d1794fe913b5ef1e4216509b7904a7ac142518b1a4d1497c78d54264e82f1904de83d161f0c069b7b260d7fc1b7a8e3dbe33fcb785bc502eb
|
data/ext/binomial.c
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
#include "randomext.h"
|
2
2
|
|
3
|
+
/*
|
4
|
+
* Document-class: Random::Binomial
|
5
|
+
*
|
6
|
+
* A random sampler from the binoial distribution.
|
7
|
+
*
|
8
|
+
* This sampler uses table plus square histgram method with
|
9
|
+
* Robin Hoot method. This method constructs a table for each
|
10
|
+
* distribution. If you once construct the table, you can
|
11
|
+
* draw a random sample fast for large n (n >= 40), but the
|
12
|
+
* cost of the table construction is expensive. Therefore,
|
13
|
+
* if you need to draw many samples from the same binomial distribution,
|
14
|
+
* you had better to use this class. Otherwise, you should use
|
15
|
+
* {Random#binomial}.
|
16
|
+
*
|
17
|
+
*/
|
3
18
|
typedef struct {
|
4
19
|
int n;
|
5
20
|
double theta;
|
@@ -54,8 +69,8 @@ static void check_binomial_params(int n, double theta, const char* method_name)
|
|
54
69
|
* Inverse function method is used.
|
55
70
|
*
|
56
71
|
* @overload binomial(n, theta)
|
57
|
-
*
|
58
|
-
*
|
72
|
+
* @param [Integer] n the number of trials (n > 0)
|
73
|
+
* @param [Float] theta success probability (0 < theta < 1)
|
59
74
|
* @return [Integer] a random sample in 0..n
|
60
75
|
*/
|
61
76
|
static VALUE random_binomial_inv(VALUE self, VALUE num, VALUE prob)
|
@@ -137,7 +152,6 @@ static void fill_binomial_VK_table(binomial_t *bin, double ntheta[])
|
|
137
152
|
static void fill_binomial_T_VT_table(binomial_t *bin)
|
138
153
|
{
|
139
154
|
int k, i, x;
|
140
|
-
int nt;
|
141
155
|
int *qt = ALLOC_N(int, bin->n + 2);
|
142
156
|
double *theta = ALLOC_N(double, bin->n + 1);
|
143
157
|
double *ntheta = ALLOC_N(double, bin->n + 1);
|
@@ -145,7 +159,6 @@ static void fill_binomial_T_VT_table(binomial_t *bin)
|
|
145
159
|
|
146
160
|
for (k=7; ;k++) {
|
147
161
|
int b = pow2(k);
|
148
|
-
nt = 0;
|
149
162
|
qt[0] = 0;
|
150
163
|
for (x=0; x<=bin->n; x++) {
|
151
164
|
qt[x+1] = floor(b*bin->p[x]) + qt[x];
|
@@ -200,19 +213,10 @@ static VALUE binomial_alloc(VALUE klass)
|
|
200
213
|
/*
|
201
214
|
* Returns a random sampler from a binomial distribution.
|
202
215
|
*
|
203
|
-
* This sampler uses table plus square histgram method with
|
204
|
-
* Robin Hoot method. This method constructs a table for each
|
205
|
-
* distribution. If you once construct the table, you can
|
206
|
-
* draw a random sample fast for large n (n >= 40), but the
|
207
|
-
* cost of the table construction is expensive. Therefore,
|
208
|
-
* if you need to draw many samples from the same binomial distribution,
|
209
|
-
* you had better to use this class. Otherwise, you should use
|
210
|
-
* Random#binomial.
|
211
|
-
*
|
212
216
|
* @overload initialize(rng, n, theta)
|
213
|
-
*
|
214
|
-
*
|
215
|
-
*
|
217
|
+
* @param [Random] rng a random number generator
|
218
|
+
* @param [Integer] n the number of trials (n > 0)
|
219
|
+
* @param [Float] theta success probability (0 < theta < 1)
|
216
220
|
* @return [Random::Binomial] a random number generator from the specified binomial distribution
|
217
221
|
*/
|
218
222
|
static VALUE binomial_initialize(VALUE self, VALUE rng, VALUE num, VALUE prob)
|
@@ -265,7 +269,8 @@ static VALUE binomial_rand(VALUE self)
|
|
265
269
|
}
|
266
270
|
|
267
271
|
/*
|
268
|
-
*
|
272
|
+
* Returns the parameter n, the number of trials.
|
273
|
+
*
|
269
274
|
* @return [Integer] the parameter n
|
270
275
|
*/
|
271
276
|
static VALUE binomial_n(VALUE self)
|
@@ -277,7 +282,8 @@ static VALUE binomial_n(VALUE self)
|
|
277
282
|
}
|
278
283
|
|
279
284
|
/*
|
280
|
-
*
|
285
|
+
* Returns the parameter theta, the success probability.
|
286
|
+
*
|
281
287
|
* @return [Float] the parameter theta
|
282
288
|
*/
|
283
289
|
static VALUE binomial_theta(VALUE self)
|
@@ -288,27 +294,6 @@ static VALUE binomial_theta(VALUE self)
|
|
288
294
|
return DBL2NUM(bin->theta);
|
289
295
|
}
|
290
296
|
|
291
|
-
#if 0
|
292
|
-
static VALUE binomial_debug_info(VALUE self)
|
293
|
-
{
|
294
|
-
binomial_t *bin;
|
295
|
-
int i;
|
296
|
-
|
297
|
-
Data_Get_Struct(self, binomial_t, bin);
|
298
|
-
|
299
|
-
|
300
|
-
printf("N=%d\n", bin->N);
|
301
|
-
for (i=0; i<bin->N; ++i) {
|
302
|
-
printf("%d ", bin->T[i]);
|
303
|
-
}
|
304
|
-
puts("");
|
305
|
-
for (i=0; i<=bin->n; ++i) {
|
306
|
-
printf("%f %d\n", bin->V[i], bin->K[i]);
|
307
|
-
}
|
308
|
-
return Qnil;
|
309
|
-
}
|
310
|
-
#endif
|
311
|
-
|
312
297
|
void randomext_binomial_init(VALUE cRandom)
|
313
298
|
{
|
314
299
|
VALUE cBinomial = rb_define_class_under(cRandom, "Binomial", rb_cObject);
|
@@ -319,5 +304,4 @@ void randomext_binomial_init(VALUE cRandom)
|
|
319
304
|
rb_define_method(cBinomial, "rand", binomial_rand, 0);
|
320
305
|
rb_define_method(cBinomial, "n", binomial_n, 0);
|
321
306
|
rb_define_method(cBinomial, "theta", binomial_theta, 0);
|
322
|
-
//rb_define_method(cBinomial, "debug_info", binomial_debug_info, 0);
|
323
307
|
}
|
data/ext/hypergeometric.c
CHANGED
@@ -26,9 +26,9 @@ static inline double hypergeometric_distribution(int x, int N, int M, int n)
|
|
26
26
|
* Inverse method is used.
|
27
27
|
*
|
28
28
|
* @overload hypergeometric(N, M, n)
|
29
|
-
*
|
30
|
-
*
|
31
|
-
*
|
29
|
+
* @param [Integer] N a population (N >= 0)
|
30
|
+
* @param [Integer] M the number of successes (0 <= M <= N)
|
31
|
+
* @param [Integer] n the number of samples (0 <= n <= N)
|
32
32
|
* @return [Integer] a random sample in [max(0, n-(N-M)), min(n, M)]
|
33
33
|
*/
|
34
34
|
static VALUE random_hypergoemtric_inv(VALUE self, VALUE vN, VALUE vM, VALUE vn)
|
data/ext/other.c
CHANGED
@@ -6,9 +6,9 @@
|
|
6
6
|
* The return value is contained in [-PI, PI].
|
7
7
|
*
|
8
8
|
* @overload vonmises(mu, kappa)
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
9
|
+
* @param [Float] mu direction parameter (-PI <= mu <= PI)
|
10
|
+
* @param [Float] kappa concentration parameter (kappa > 0)
|
11
|
+
* @return [Float] A random sample in [-PI, PI]
|
12
12
|
*/
|
13
13
|
static VALUE random_vonmises(VALUE self, VALUE vmu, VALUE vkappa)
|
14
14
|
{
|
@@ -53,10 +53,10 @@ static VALUE random_vonmises(VALUE self, VALUE vmu, VALUE vkappa)
|
|
53
53
|
* In case of q == 0.0, the distribution is called a Zipf distribution.
|
54
54
|
*
|
55
55
|
* @overload zipf_mandelbrot(n, q=0.0, s=1.0)
|
56
|
-
*
|
57
|
-
*
|
58
|
-
*
|
59
|
-
*
|
56
|
+
* @param [Integer] n the maximum of return value (n > 0)
|
57
|
+
* @param [Float] q a parameter (q >= 0.0)
|
58
|
+
* @param [Float] s a parameter (s > 0.0)
|
59
|
+
* @return [Integer] a random sample in 1..n
|
60
60
|
*/
|
61
61
|
static VALUE random_zipf(int argc, VALUE *argv, VALUE self)
|
62
62
|
{
|
@@ -94,7 +94,7 @@ static VALUE random_zipf(int argc, VALUE *argv, VALUE self)
|
|
94
94
|
* Draws a random sample from a zeta distribution.
|
95
95
|
*
|
96
96
|
* @overload zeta(s)
|
97
|
-
*
|
97
|
+
* @param [Integer] s a parameter (s > 0.0)
|
98
98
|
* @return [Integer] a random sample in [1, INFINITY)
|
99
99
|
*/
|
100
100
|
static VALUE random_zeta(VALUE self, VALUE vs)
|
data/ext/poisson.c
CHANGED
@@ -23,7 +23,7 @@ static inline double backward_ratio(int x, double lambda)
|
|
23
23
|
* Inverse function method is used.
|
24
24
|
*
|
25
25
|
* @overload poisson(lambda)
|
26
|
-
*
|
26
|
+
* @param [Float] lambda mean
|
27
27
|
* @return [Integer] a random sample in [0, INFINITY)
|
28
28
|
*/
|
29
29
|
static VALUE random_poisson_inv(VALUE self, VALUE l)
|
data/ext/standard_normal.c
CHANGED
@@ -6,40 +6,13 @@
|
|
6
6
|
#define M 64
|
7
7
|
#define N (1<<K)
|
8
8
|
|
9
|
-
|
10
|
-
static uint64_t* k;
|
11
|
-
static double* f;
|
9
|
+
#include "standard_normal_table.h"
|
12
10
|
|
13
11
|
inline static double sn(double x)
|
14
12
|
{
|
15
13
|
return exp(-x*x/2);
|
16
14
|
}
|
17
15
|
|
18
|
-
static void init_snormal_table(void)
|
19
|
-
{
|
20
|
-
int i;
|
21
|
-
double xi;
|
22
|
-
|
23
|
-
w = ALLOC_N(double, N);
|
24
|
-
k = ALLOC_N(uint64_t, N);
|
25
|
-
f = ALLOC_N(double, N);
|
26
|
-
|
27
|
-
w[N-1] = V*exp(R*R/2)/pow2(M-K-1);
|
28
|
-
w[N-2] = R/pow2(M-K-1);
|
29
|
-
k[N-1] = floor(R/w[N-1]);
|
30
|
-
f[N-1] = sn(R);
|
31
|
-
xi = R;
|
32
|
-
|
33
|
-
for (i=N-2; i>=1; --i) {
|
34
|
-
xi = sqrt(-2*log(sn(xi)+V/xi));
|
35
|
-
w[i-1] = xi/pow2(M-K-1);
|
36
|
-
k[i] = floor(xi/w[i]);
|
37
|
-
f[i] = sn(xi);
|
38
|
-
}
|
39
|
-
k[0] = 0;
|
40
|
-
f[0] = 1;
|
41
|
-
}
|
42
|
-
|
43
16
|
static double sample_from_tail(VALUE random)
|
44
17
|
{
|
45
18
|
for (;;) {
|
@@ -56,9 +29,6 @@ double randomext_random_standard_normal(VALUE random)
|
|
56
29
|
int sign;
|
57
30
|
double ux;
|
58
31
|
|
59
|
-
if (w == NULL)
|
60
|
-
init_snormal_table();
|
61
|
-
|
62
32
|
for (;;) {
|
63
33
|
unsigned int u0 = rb_random_int32(random);
|
64
34
|
i = u0 & MASK(K);
|
@@ -0,0 +1,392 @@
|
|
1
|
+
static double w[N] = {
|
2
|
+
3.779211177528728e-18,
|
3
|
+
5.035852722282574e-18,
|
4
|
+
5.919542444491104e-18,
|
5
|
+
6.625780997425304e-18,
|
6
|
+
7.225554026797095e-18,
|
7
|
+
7.753411501834412e-18,
|
8
|
+
8.22901389351605e-18,
|
9
|
+
8.66471612981438e-18,
|
10
|
+
9.068837885372816e-18,
|
11
|
+
9.447275165901862e-18,
|
12
|
+
9.804374136660416e-18,
|
13
|
+
1.0143440402100701e-17,
|
14
|
+
1.046705311944029e-17,
|
15
|
+
1.0777267798949829e-17,
|
16
|
+
1.1075752268719609e-17,
|
17
|
+
1.1363880762787455e-17,
|
18
|
+
1.164280081091786e-17,
|
19
|
+
1.1913481912009988e-17,
|
20
|
+
1.2176751677985312e-17,
|
21
|
+
1.2433323156881527e-17,
|
22
|
+
1.2683815817413517e-17,
|
23
|
+
1.2928771894948216e-17,
|
24
|
+
1.3168669287123936e-17,
|
25
|
+
1.3403931845028942e-17,
|
26
|
+
1.3634937672194328e-17,
|
27
|
+
1.386202588123086e-17,
|
28
|
+
1.408550214314811e-17,
|
29
|
+
1.4305643282033703e-17,
|
30
|
+
1.452270110785588e-17,
|
31
|
+
1.4736905636009493e-17,
|
32
|
+
1.494846780931835e-17,
|
33
|
+
1.5157581813408613e-17,
|
34
|
+
1.5364427057490915e-17,
|
35
|
+
1.5569169878084408e-17,
|
36
|
+
1.57719650119731e-17,
|
37
|
+
1.5972956875899105e-17,
|
38
|
+
1.6172280683578905e-17,
|
39
|
+
1.6370063425141637e-17,
|
40
|
+
1.6566424729707162e-17,
|
41
|
+
1.6761477628301348e-17,
|
42
|
+
1.6955329231460542e-17,
|
43
|
+
1.7148081333564528e-17,
|
44
|
+
1.7339830954047733e-17,
|
45
|
+
1.7530670824087173e-17,
|
46
|
+
1.772068982608615e-17,
|
47
|
+
1.7909973392213292e-17,
|
48
|
+
1.8098603867375507e-17,
|
49
|
+
1.8286660841268705e-17,
|
50
|
+
1.8474221453535323e-17,
|
51
|
+
1.8661360675541846e-17,
|
52
|
+
1.8848151571856147e-17,
|
53
|
+
1.9034665544139553e-17,
|
54
|
+
1.922097255986149e-17,
|
55
|
+
1.94071413679859e-17,
|
56
|
+
1.959323970356166e-17,
|
57
|
+
1.9779334482967482e-17,
|
58
|
+
1.996549199141056e-17,
|
59
|
+
2.015177806415392e-17,
|
60
|
+
2.0338258262846282e-17,
|
61
|
+
2.052499804824809e-17,
|
62
|
+
2.071206295058628e-17,
|
63
|
+
2.0899518738726243e-17,
|
64
|
+
2.108743158932197e-17,
|
65
|
+
2.127586825709298e-17,
|
66
|
+
2.146489624737944e-17,
|
67
|
+
2.1654583992144607e-17,
|
68
|
+
2.1845001030626488e-17,
|
69
|
+
2.203621819588908e-17,
|
70
|
+
2.2228307808588562e-17,
|
71
|
+
2.2421343879352476e-17,
|
72
|
+
2.2615402321272053e-17,
|
73
|
+
2.2810561174131224e-17,
|
74
|
+
2.3006900842143298e-17,
|
75
|
+
2.3204504347140732e-17,
|
76
|
+
2.3403457599368684e-17,
|
77
|
+
2.360384968827396e-17,
|
78
|
+
2.3805773195962715e-17,
|
79
|
+
2.4009324536330014e-17,
|
80
|
+
2.421460432324996e-17,
|
81
|
+
2.4421717771666483e-17,
|
82
|
+
2.4630775135954096e-17,
|
83
|
+
2.4841892190539375e-17,
|
84
|
+
2.5055190758505437e-17,
|
85
|
+
2.527079929476491e-17,
|
86
|
+
2.548885353140859e-17,
|
87
|
+
2.5709497194049845e-17,
|
88
|
+
2.5932882799429966e-17,
|
89
|
+
2.6159172546277296e-17,
|
90
|
+
2.6388539313487046e-17,
|
91
|
+
2.6621167782188563e-17,
|
92
|
+
2.6857255701293365e-17,
|
93
|
+
2.7097015319798532e-17,
|
94
|
+
2.7340675013619677e-17,
|
95
|
+
2.7588481140256304e-17,
|
96
|
+
2.7840700161422706e-17,
|
97
|
+
2.809762108226512e-17,
|
98
|
+
2.835955826639796e-17,
|
99
|
+
2.8626854699347176e-17,
|
100
|
+
2.889988578991277e-17,
|
101
|
+
2.917906382056743e-17,
|
102
|
+
2.946484318580545e-17,
|
103
|
+
2.9757726593421176e-17,
|
104
|
+
3.0058272450907446e-17,
|
105
|
+
3.0367103721563165e-17,
|
106
|
+
3.068491861822208e-17,
|
107
|
+
3.101250361502133e-17,
|
108
|
+
3.1350749411368486e-17,
|
109
|
+
3.170067069509885e-17,
|
110
|
+
3.206343085064238e-17,
|
111
|
+
3.2440373184106596e-17,
|
112
|
+
3.283306085507585e-17,
|
113
|
+
3.324332861780275e-17,
|
114
|
+
3.3673350851217557e-17,
|
115
|
+
3.412573248168003e-17,
|
116
|
+
3.460363276607498e-17,
|
117
|
+
3.511093738513032e-17,
|
118
|
+
3.565250353172647e-17,
|
119
|
+
3.623451883582939e-17,
|
120
|
+
3.686504450680305e-17,
|
121
|
+
3.75548699516312e-17,
|
122
|
+
3.831892265142546e-17,
|
123
|
+
3.9178734569779584e-17,
|
124
|
+
4.0167091972264215e-17,
|
125
|
+
4.1337714538177976e-17,
|
126
|
+
4.2788395857263743e-17,
|
127
|
+
4.472928950257001e-17,
|
128
|
+
4.777594786313511e-17,
|
129
|
+
5.1529423044407315e-17,
|
130
|
+
};
|
131
|
+
|
132
|
+
static uint64_t k[N] = {
|
133
|
+
0,
|
134
|
+
54076415620536904,
|
135
|
+
61300587756530160,
|
136
|
+
64377012539529264,
|
137
|
+
66076294707096096,
|
138
|
+
67151864522975000,
|
139
|
+
67892968177924664,
|
140
|
+
68434202989192568,
|
141
|
+
68846593712197952,
|
142
|
+
69171123658870632,
|
143
|
+
69433082538507880,
|
144
|
+
69648914306148520,
|
145
|
+
69829769879067288,
|
146
|
+
69983476194917440,
|
147
|
+
70115687770302160,
|
148
|
+
70230590878559368,
|
149
|
+
70331350677449488,
|
150
|
+
70420404420292040,
|
151
|
+
70499659178058240,
|
152
|
+
70570628466878520,
|
153
|
+
70634528715794040,
|
154
|
+
70692348697106704,
|
155
|
+
70744900361805480,
|
156
|
+
70792856639540568,
|
157
|
+
70836779941489144,
|
158
|
+
70877143927839008,
|
159
|
+
70914350325727000,
|
160
|
+
70948742062233352,
|
161
|
+
70980613620876648,
|
162
|
+
71010219282873288,
|
163
|
+
71037779740400504,
|
164
|
+
71063487444945400,
|
165
|
+
71087510964150584,
|
166
|
+
71109998555058080,
|
167
|
+
71131081113284408,
|
168
|
+
71150874621589976,
|
169
|
+
71169482194156344,
|
170
|
+
71186995792270104,
|
171
|
+
71203497671331240,
|
172
|
+
71219061606927376,
|
173
|
+
71233753938254240,
|
174
|
+
71247634459757496,
|
175
|
+
71260757186039240,
|
176
|
+
71273171010449816,
|
177
|
+
71284920274100840,
|
178
|
+
71296045259079904,
|
179
|
+
71306582617266824,
|
180
|
+
71316565744221304,
|
181
|
+
71326025106040584,
|
182
|
+
71334988525801840,
|
183
|
+
71343481435146536,
|
184
|
+
71351527095693856,
|
185
|
+
71359146794246632,
|
186
|
+
71366360015153064,
|
187
|
+
71373184592683680,
|
188
|
+
71379636845862160,
|
189
|
+
71385731697832616,
|
190
|
+
71391482781545128,
|
191
|
+
71396902533285504,
|
192
|
+
71402002275357128,
|
193
|
+
71406792289034624,
|
194
|
+
71411281878747928,
|
195
|
+
71415479428314056,
|
196
|
+
71419392449911592,
|
197
|
+
71423027626383784,
|
198
|
+
71426390847360208,
|
199
|
+
71429487239599328,
|
200
|
+
71432321191875536,
|
201
|
+
71434896374660288,
|
202
|
+
71437215754778184,
|
203
|
+
71439281605151936,
|
204
|
+
71441095509685592,
|
205
|
+
71442658363269824,
|
206
|
+
71443970366826712,
|
207
|
+
71445031017241888,
|
208
|
+
71445839091957312,
|
209
|
+
71446392627917936,
|
210
|
+
71446688894475496,
|
211
|
+
71446724359753304,
|
212
|
+
71446494649861640,
|
213
|
+
71445994500222504,
|
214
|
+
71445217698110208,
|
215
|
+
71444157015336032,
|
216
|
+
71442804129794104,
|
217
|
+
71441149534335072,
|
218
|
+
71439182431133664,
|
219
|
+
71436890609354568,
|
220
|
+
71434260303482624,
|
221
|
+
71431276029149600,
|
222
|
+
71427920392635256,
|
223
|
+
71424173869414824,
|
224
|
+
71420014546126464,
|
225
|
+
71415417819088288,
|
226
|
+
71410356040935128,
|
227
|
+
71404798104978112,
|
228
|
+
71398708954393280,
|
229
|
+
71392049000153288,
|
230
|
+
71384773427507192,
|
231
|
+
71376831365482520,
|
232
|
+
71368164886913096,
|
233
|
+
71358707797302752,
|
234
|
+
71348384158599168,
|
235
|
+
71337106477510176,
|
236
|
+
71324773465667520,
|
237
|
+
71311267248289504,
|
238
|
+
71296449855397552,
|
239
|
+
71280158769685808,
|
240
|
+
71262201219561744,
|
241
|
+
71242346781854352,
|
242
|
+
71220317675959912,
|
243
|
+
71195775857061400,
|
244
|
+
71168305596529440,
|
245
|
+
71137389581305912,
|
246
|
+
71102375511978928,
|
247
|
+
71062428446027928,
|
248
|
+
71016461188283864,
|
249
|
+
70963029851113296,
|
250
|
+
70900172224299768,
|
251
|
+
70825148412611304,
|
252
|
+
70734006393383296,
|
253
|
+
70620815666934008,
|
254
|
+
70476226522053056,
|
255
|
+
70284534227628608,
|
256
|
+
70017030195232984,
|
257
|
+
69614581079045472,
|
258
|
+
68930870409638744,
|
259
|
+
67462502132127024,
|
260
|
+
66808818195620008,
|
261
|
+
};
|
262
|
+
|
263
|
+
static double f[N] = {
|
264
|
+
1.0,
|
265
|
+
0.9635996931270862,
|
266
|
+
0.9362826816850596,
|
267
|
+
0.9130436479717402,
|
268
|
+
0.8922816507840261,
|
269
|
+
0.8732430489100695,
|
270
|
+
0.8555006078694506,
|
271
|
+
0.8387836052959896,
|
272
|
+
0.822907211381409,
|
273
|
+
0.8077382946829605,
|
274
|
+
0.7931770117713051,
|
275
|
+
0.7791460859296877,
|
276
|
+
0.7655841738977045,
|
277
|
+
0.7524415591746114,
|
278
|
+
0.7396772436726473,
|
279
|
+
0.7272569183441848,
|
280
|
+
0.7151515074104986,
|
281
|
+
0.7033360990161581,
|
282
|
+
0.6917891434366751,
|
283
|
+
0.6804918409973341,
|
284
|
+
0.6694276673488904,
|
285
|
+
0.658582000050088,
|
286
|
+
0.6479418211102225,
|
287
|
+
0.6374954773350423,
|
288
|
+
0.6272324852499273,
|
289
|
+
0.6171433708188809,
|
290
|
+
0.6072195366251203,
|
291
|
+
0.5974531509445167,
|
292
|
+
0.5878370544347066,
|
293
|
+
0.5783646811197631,
|
294
|
+
0.5690299910679509,
|
295
|
+
0.5598274127040869,
|
296
|
+
0.5507517931146045,
|
297
|
+
0.5417983550254255,
|
298
|
+
0.5329626593838361,
|
299
|
+
0.5242405726729841,
|
300
|
+
0.5156282382440018,
|
301
|
+
0.507122051075569,
|
302
|
+
0.4987186354709795,
|
303
|
+
0.4904148252838441,
|
304
|
+
0.4822076463294852,
|
305
|
+
0.47409430069301695,
|
306
|
+
0.4660721526894561,
|
307
|
+
0.45813871626787206,
|
308
|
+
0.4502916436820392,
|
309
|
+
0.44252871527546844,
|
310
|
+
0.4348478302499909,
|
311
|
+
0.4272469983049961,
|
312
|
+
0.4197243320495744,
|
313
|
+
0.412278040102661,
|
314
|
+
0.40490642080722294,
|
315
|
+
0.3976078564938733,
|
316
|
+
0.3903808082373146,
|
317
|
+
0.3832238110559012,
|
318
|
+
0.3761354695105626,
|
319
|
+
0.3691144536644722,
|
320
|
+
0.3621594953693176,
|
321
|
+
0.3552693848479171,
|
322
|
+
0.3484429675463266,
|
323
|
+
0.3416791412315504,
|
324
|
+
0.3349768533135892,
|
325
|
+
0.3283350983728503,
|
326
|
+
0.3217529158759849,
|
327
|
+
0.3152293880650109,
|
328
|
+
0.3087636380061811,
|
329
|
+
0.30235482778648354,
|
330
|
+
0.296002156846933,
|
331
|
+
0.28970486044295984,
|
332
|
+
0.283462208223233,
|
333
|
+
0.2772735029191881,
|
334
|
+
0.2711380791383846,
|
335
|
+
0.2650553022555892,
|
336
|
+
0.25902456739620483,
|
337
|
+
0.25304529850732577,
|
338
|
+
0.2471169475123214,
|
339
|
+
0.24123899354543982,
|
340
|
+
0.23541094226347908,
|
341
|
+
0.22963232523211613,
|
342
|
+
0.22390269938500842,
|
343
|
+
0.2182216465543054,
|
344
|
+
0.2125887730717303,
|
345
|
+
0.20700370943992652,
|
346
|
+
0.20146611007431367,
|
347
|
+
0.19597565311627774,
|
348
|
+
0.19053204031913715,
|
349
|
+
0.1851349970089922,
|
350
|
+
0.17978427212329545,
|
351
|
+
0.1744796383307895,
|
352
|
+
0.169220892237365,
|
353
|
+
0.16400785468342038,
|
354
|
+
0.1588403711394793,
|
355
|
+
0.15371831220818166,
|
356
|
+
0.14864157424234226,
|
357
|
+
0.14361008009062776,
|
358
|
+
0.1386237799845946,
|
359
|
+
0.13368265258343937,
|
360
|
+
0.1287867061959432,
|
361
|
+
0.12393598020286782,
|
362
|
+
0.11913054670765083,
|
363
|
+
0.11437051244886601,
|
364
|
+
0.10965602101484027,
|
365
|
+
0.10498725540942132,
|
366
|
+
0.10036444102865587,
|
367
|
+
0.09578784912173144,
|
368
|
+
0.09125780082683026,
|
369
|
+
0.08677467189478018,
|
370
|
+
0.08233889824223566,
|
371
|
+
0.0779509825139734,
|
372
|
+
0.0736115018841134,
|
373
|
+
0.06932111739357791,
|
374
|
+
0.06508058521306807,
|
375
|
+
0.060890770348040406,
|
376
|
+
0.05675266348104985,
|
377
|
+
0.05266740190305101,
|
378
|
+
0.048636295859867805,
|
379
|
+
0.044660862200491425,
|
380
|
+
0.040742868074444175,
|
381
|
+
0.0368843887866562,
|
382
|
+
0.03308788614622575,
|
383
|
+
0.02935631744000685,
|
384
|
+
0.02569329193593427,
|
385
|
+
0.022103304615927098,
|
386
|
+
0.018592102737011288,
|
387
|
+
0.015167298010546568,
|
388
|
+
0.011839478657884862,
|
389
|
+
0.008624484412859885,
|
390
|
+
0.005548995220771345,
|
391
|
+
0.002669629083880923,
|
392
|
+
};
|
metadata
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: randomext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Ippei Obayashi
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-12-17 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
|
-
description:
|
13
|
+
description: "This library extends class Random in the Ruby standard library.\nThe
|
15
14
|
Random class in the Ruby standard library supports only \nrandom sampling from discrete/continuous
|
16
15
|
uniform distribution.\n\nThis library provides random sampling methods from \nmany
|
17
16
|
kinds of probability distributions such as normal, gamma,\nbeta, chi_square, t,
|
@@ -22,39 +21,41 @@ extensions:
|
|
22
21
|
- ext/extconf.rb
|
23
22
|
extra_rdoc_files: []
|
24
23
|
files:
|
25
|
-
-
|
24
|
+
- ext/binomial.c
|
26
25
|
- ext/extconf.rb
|
27
|
-
- ext/
|
28
|
-
- ext/randomext.h
|
29
|
-
- ext/other.c
|
26
|
+
- ext/gamma.c
|
30
27
|
- ext/hypergeometric.c
|
31
|
-
- ext/
|
28
|
+
- ext/other.c
|
32
29
|
- ext/poisson.c
|
33
|
-
- ext/
|
34
|
-
- ext/
|
30
|
+
- ext/randomext.h
|
31
|
+
- ext/randomext_native.c
|
32
|
+
- ext/standard_exponential.c
|
35
33
|
- ext/standard_normal.c
|
34
|
+
- ext/standard_normal_table.h
|
35
|
+
- lib/randomext.rb
|
36
36
|
homepage: http://www.kmc.gr.jp/~ohai/randomext/
|
37
|
-
licenses:
|
37
|
+
licenses:
|
38
|
+
- BSD-2-Clause
|
39
|
+
metadata: {}
|
38
40
|
post_install_message:
|
39
41
|
rdoc_options: []
|
40
42
|
require_paths:
|
41
43
|
- lib
|
42
44
|
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
45
|
requirements:
|
45
|
-
- -
|
46
|
+
- - ">="
|
46
47
|
- !ruby/object:Gem::Version
|
47
48
|
version: '0'
|
48
49
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0'
|
54
54
|
requirements: []
|
55
55
|
rubyforge_project:
|
56
|
-
rubygems_version:
|
56
|
+
rubygems_version: 2.4.5.1
|
57
57
|
signing_key:
|
58
|
-
specification_version:
|
58
|
+
specification_version: 4
|
59
59
|
summary: This library extend Random class of Ruby standard library
|
60
60
|
test_files: []
|
61
|
+
has_rdoc: false
|