summaryrefslogtreecommitdiffstats
path: root/stats-php7.patch
blob: 761cb4ac81e36dc196c96b031f6f2fc8d7870573 (plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
diff --git a/php_stats.c b/php_stats.c
index 32dc4e9..7d155a8 100644
--- a/php_stats.c
+++ b/php_stats.c
@@ -16,9 +16,6 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id$ */
-
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -83,7 +80,8 @@ zend_function_entry statistics_functions[] = {
 	PHP_FE(stats_rand_gen_f,			NULL)
 	PHP_FE(stats_rand_gen_gamma,		NULL)
 	PHP_FE(stats_rand_gen_noncentral_chisquare,NULL)
-	PHP_FE(stats_rand_gen_noncenral_f,	NULL)
+	PHP_FE(stats_rand_gen_noncentral_f,	NULL)
+	PHP_DEP_FALIAS(stats_rand_gen_noncenral_f,	stats_rand_gen_noncentral_f,	NULL)
 	PHP_FE(stats_rand_gen_normal,		NULL)
 	PHP_FE(stats_rand_phrase_to_seeds,	NULL)
 	PHP_FE(stats_rand_ibinomial,		NULL)
@@ -129,12 +127,12 @@ zend_module_entry stats_module_entry = {
 	STANDARD_MODULE_HEADER,
 	"stats",
 	statistics_functions,
- 	NULL,
- 	NULL,
- 	NULL,
- 	NULL,
- 	PHP_MINFO(stats),
- 	PHP_STATS_VERSION,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	PHP_MINFO(stats),
+	PHP_STATS_VERSION,
 	STANDARD_MODULE_PROPERTIES,
 };
 
@@ -432,10 +430,10 @@ PHP_FUNCTION(stats_cdf_normal)
 	}
 
 	switch (which) {
-	  	case 1: RETURN_DOUBLE(p);
-	  	case 2: RETURN_DOUBLE(x);
-	  	case 3: RETURN_DOUBLE(mean);
-	  	case 4: RETURN_DOUBLE(sd);
+		case 1: RETURN_DOUBLE(p);
+		case 2: RETURN_DOUBLE(x);
+		case 3: RETURN_DOUBLE(mean);
+		case 4: RETURN_DOUBLE(sd);
 	}
 	RETURN_FALSE; /* should never be reached */
 }
@@ -588,10 +586,10 @@ PHP_FUNCTION(stats_cdf_gamma)
 	}
 
 	switch (which)	{
-	  	case 1: RETURN_DOUBLE(p);
-	  	case 2: RETURN_DOUBLE(x);
-	  	case 3: RETURN_DOUBLE(shape);
-	  	case 4: RETURN_DOUBLE(1 / rate);
+		case 1: RETURN_DOUBLE(p);
+		case 2: RETURN_DOUBLE(x);
+		case 3: RETURN_DOUBLE(shape);
+		case 4: RETURN_DOUBLE(1 / rate);
 	}
 	RETURN_FALSE; /* should never be reached */
 }
@@ -702,7 +700,7 @@ PHP_FUNCTION(stats_cdf_chisquare)
 		q = 1.0 - p;
 	}
 
- 	cdfchi((int *)&which, &p, &q, &x, &df, &status, &bound);
+	cdfchi((int *)&which, &p, &q, &x, &df, &status, &bound);
 	if (status != 0) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Computation Error");
 		RETURN_FALSE;
@@ -855,10 +853,10 @@ PHP_FUNCTION(stats_cdf_beta)
 	}
 
 	switch (which) {
-	  	case 1: RETURN_DOUBLE(p);
-	  	case 2: RETURN_DOUBLE(x);
-	  	case 3: RETURN_DOUBLE(a);
-	  	case 4: RETURN_DOUBLE(b);
+		case 1: RETURN_DOUBLE(p);
+		case 2: RETURN_DOUBLE(x);
+		case 3: RETURN_DOUBLE(a);
+		case 4: RETURN_DOUBLE(b);
 	}
 	RETURN_FALSE; /* never here */
 }
@@ -994,10 +992,10 @@ PHP_FUNCTION(stats_cdf_binomial)
 	}
 
 	switch (which) {
-	  	case 1: RETURN_DOUBLE(p);
-	  	case 2: RETURN_DOUBLE(sn);
-	  	case 3: RETURN_DOUBLE(xn);
-	  	case 4: RETURN_DOUBLE(pr);
+		case 1: RETURN_DOUBLE(p);
+		case 2: RETURN_DOUBLE(sn);
+		case 3: RETURN_DOUBLE(xn);
+		case 4: RETURN_DOUBLE(pr);
 	}
 	RETURN_FALSE; /* never here */
 }
@@ -1132,10 +1130,10 @@ PHP_FUNCTION(stats_cdf_noncentral_chisquare)
 	}
 
 	switch (which) {
-	  	case 1: RETURN_DOUBLE(p);
-	  	case 2: RETURN_DOUBLE(x);
-	  	case 3: RETURN_DOUBLE(df);
-	  	case 4: RETURN_DOUBLE(pnonc);
+		case 1: RETURN_DOUBLE(p);
+		case 2: RETURN_DOUBLE(x);
+		case 3: RETURN_DOUBLE(df);
+		case 4: RETURN_DOUBLE(pnonc);
 	}
 	RETURN_FALSE; /* never here */
 }
@@ -1263,10 +1261,10 @@ PHP_FUNCTION(stats_cdf_f)
 	}
 
 	switch (which) {
-	  	case 1: RETURN_DOUBLE(p);
-	  	case 2: RETURN_DOUBLE(f);
-	  	case 3: RETURN_DOUBLE(dfn);
-	  	case 4: RETURN_DOUBLE(dfd);
+		case 1: RETURN_DOUBLE(p);
+		case 2: RETURN_DOUBLE(f);
+		case 3: RETURN_DOUBLE(dfn);
+		case 4: RETURN_DOUBLE(dfd);
 	}
 	RETURN_FALSE; /* never here */
 }
@@ -1420,10 +1418,10 @@ PHP_FUNCTION(stats_cdf_noncentral_f)
 	}
 
 	switch (which) {
-	  	case 1: RETURN_DOUBLE(p);
-	  	case 2: RETURN_DOUBLE(f);
-	  	case 3: RETURN_DOUBLE(dfn);
-	  	case 4: RETURN_DOUBLE(dfd);
+		case 1: RETURN_DOUBLE(p);
+		case 2: RETURN_DOUBLE(f);
+		case 3: RETURN_DOUBLE(dfn);
+		case 4: RETURN_DOUBLE(dfd);
 		case 5: RETURN_DOUBLE(pnonc);
 	}
 	RETURN_FALSE; /* never here */
@@ -1839,7 +1837,7 @@ static double laplace_cdf(double x)
 
 
 /* {{{ proto float stats_cdf_laplace(float par1, float par2, float par3, int which)
-    Calculates any one parameter of the Laplace distribution given values for the others. */
+	Calculates any one parameter of the Laplace distribution given values for the others. */
 PHP_FUNCTION(stats_cdf_laplace)
 {
 	double arg1;
@@ -1909,7 +1907,7 @@ static double cauchy_cdf (double x)
 }
 
 /* {{{ proto float stats_cdf_cauchy(float par1, float par2, float par3, int which)
-    Calculates any one parameter of the Cauchy distribution given values for the others. */
+	Calculates any one parameter of the Cauchy distribution given values for the others. */
 PHP_FUNCTION(stats_cdf_cauchy)
 {
 	double arg1;
@@ -1978,7 +1976,7 @@ static double logistic_quantile (double p)
 }
 
 /* {{{ proto float stats_cdf_logistic(float par1, float par2, float par3, int which)
-    Calculates any one parameter of the logistic distribution given values for the others. */
+	Calculates any one parameter of the logistic distribution given values for the others. */
 PHP_FUNCTION(stats_cdf_logistic)
 {
 	double arg1;
@@ -2037,7 +2035,7 @@ PHP_FUNCTION(stats_cdf_logistic)
 /* }}} */
 
 /* {{{ proto float stats_cdf_weibull(float par1, float par2, float par3, int which)
-    Calculates any one parameter of the Weibull distribution given values for the others. */
+	Calculates any one parameter of the Weibull distribution given values for the others. */
 PHP_FUNCTION(stats_cdf_weibull)
 {
 	double arg1;
@@ -2087,7 +2085,7 @@ PHP_FUNCTION(stats_cdf_weibull)
 /* }}} */
 
 /* {{{ proto float stats_cdf_uniform(float par1, float par2, float par3, int which)
-    Calculates any one parameter of the uniform distribution given values for the others. */
+	Calculates any one parameter of the uniform distribution given values for the others. */
 PHP_FUNCTION(stats_cdf_uniform)
 {
 	double arg1;
@@ -2163,7 +2161,7 @@ static double exponential_cdf(double x)
 }
 
 /* {{{ proto float stats_cdf_exponential(float par1, float par2, int which)
-    Calculates any one parameter of the exponential distribution given values for the others. */
+	Calculates any one parameter of the exponential distribution given values for the others. */
 PHP_FUNCTION(stats_cdf_exponential)
 {
 	double arg1;
@@ -2243,7 +2241,7 @@ PHP_FUNCTION(stats_rand_getsd)
 /* }}} */
 
 /* {{{ proto int stats_rand_gen_iuniform(int low, int high)
-   Generates integer uniformly distributed between LOW (inclusive) and HIGH (inclusive)  */
+	Generates integer uniformly distributed between LOW (inclusive) and HIGH (inclusive)  */
 PHP_FUNCTION(stats_rand_gen_iuniform)
 {
 	zend_long low;
@@ -2267,7 +2265,7 @@ PHP_FUNCTION(stats_rand_gen_iuniform)
 /* }}} */
 
 /* {{{ proto float stats_rand_gen_funiform(float low, float high)
-   Generates uniform float between low (exclusive) and high (exclusive) */
+	Generates uniform float between low (exclusive) and high (exclusive) */
 PHP_FUNCTION(stats_rand_gen_funiform)
 {
 	double low;
@@ -2287,7 +2285,7 @@ PHP_FUNCTION(stats_rand_gen_funiform)
 /* }}} */
 
 /* {{{ proto int stats_rand_ignlgi(void)
-  Generates random integer between 1 and 2147483562 */
+	Generates random integer between 1 and 2147483562 */
 PHP_FUNCTION(stats_rand_ignlgi)
 {
 	if (ZEND_NUM_ARGS() != 0) {
@@ -2299,7 +2297,7 @@ PHP_FUNCTION(stats_rand_ignlgi)
 /* }}} */
 
 /* {{{ proto float stats_rand_ranf(void)
-  Returns a random floating point number from a uniform distribution over 0 - 1 (endpoints of this interval are not returned) using the current generator */
+	Returns a random floating point number from a uniform distribution over 0 - 1 (endpoints of this interval are not returned) using the current generator */
 PHP_FUNCTION(stats_rand_ranf)
 {
 	if (ZEND_NUM_ARGS() != 0) {
@@ -2428,9 +2426,9 @@ PHP_FUNCTION(stats_rand_gen_noncentral_chisquare)
 }
 /* }}} */
 
-/* {{{ proto float stats_rand_gen_noncenral_f(float dfn, float dfd, float xnonc)
+/* {{{ proto float stats_rand_gen_noncentral_f(float dfn, float dfd, float xnonc)
 	Generates a random deviate from the noncentral F (variance ratio) distribution with "dfn" degrees of freedom  in the numerator, and "dfd" degrees of freedom in the denominator, and noncentrality parameter "xnonc". Method : directly generates ratio of noncentral numerator chisquare variate to central denominator chisquare variate. */
-PHP_FUNCTION(stats_rand_gen_noncenral_f)
+PHP_FUNCTION(stats_rand_gen_noncentral_f)
 {
 	double dfn;
 	double dfd;
@@ -2895,7 +2893,7 @@ PHP_FUNCTION(stats_dens_exponential)
 /* }}} */
 
 /* {{{ proto float stats_dens_f(float x, float dfr1, float dfr2)
-    Not documented */
+	Not documented */
 PHP_FUNCTION(stats_dens_f)
 {
 	double dfr1;
@@ -3010,7 +3008,7 @@ PHP_FUNCTION(stats_dens_pmf_negative_binomial)
 /* }}} */
 
 /* {{{ proto float stats_dens_pmf_hypergeometric(float n1, float n2, float N1, float N2)
-    Not documented */
+	Not documented */
 PHP_FUNCTION(stats_dens_pmf_hypergeometric)
 {
 	double y;
@@ -3071,7 +3069,7 @@ PHP_FUNCTION(stats_stat_powersum)
 /* }}} */
 
 /* {{{ proto float stats_stat_innerproduct(array arr1, array arr2)
-    Not documented */
+	Not documented */
 PHP_FUNCTION(stats_stat_innerproduct)
 {
 	zval *arg1, *arg2;
@@ -3231,7 +3229,7 @@ PHP_FUNCTION(stats_stat_paired_t)
 /* }}} */
 
 /* {{{ proto float stats_stat_percentile(array arr, float perc)
-    Not documented */
+	Not documented */
 PHP_FUNCTION(stats_stat_percentile)
 {
 	zval *arg1, *arg2;
@@ -3459,7 +3457,7 @@ static long double php_population_variance(zval *arr, zend_bool sample)
 
 
 /* {{{ proto float stats_variance(array a [, bool sample = false])
-    Returns the population variance */
+	Returns the population variance */
 PHP_FUNCTION(stats_variance)
 {
 	zval *arr;
@@ -3481,7 +3479,7 @@ PHP_FUNCTION(stats_variance)
 /* }}} */
 
 /* {{{ proto float stats_standard_deviation(array a [, bool sample = false])
-    Returns the standard deviation */
+	Returns the standard deviation */
 PHP_FUNCTION(stats_standard_deviation)
 {
 	zval *arr;
@@ -3504,7 +3502,7 @@ PHP_FUNCTION(stats_standard_deviation)
 
 
 /* {{{ proto float stats_absolute_deviation(array a)
-    Returns the absolute deviation of an array of values */
+	Returns the absolute deviation of an array of values */
 PHP_FUNCTION(stats_absolute_deviation)
 {
 	zval *arr;
@@ -3534,7 +3532,7 @@ PHP_FUNCTION(stats_absolute_deviation)
 /* }}} */
 
 /* {{{ proto float stats_harmonic_mean(array a)
-    Returns the harmonic mean of an array of values */
+	Returns the harmonic mean of an array of values */
 PHP_FUNCTION(stats_harmonic_mean)
 {
 	zval *arr;
@@ -3566,7 +3564,7 @@ PHP_FUNCTION(stats_harmonic_mean)
 /* }}} */
 
 /* {{{ proto float stats_skew(array a)
-    Computes the skewness of the data in the array */
+	Computes the skewness of the data in the array */
 PHP_FUNCTION(stats_skew)
 {
 	zval *arr;
@@ -3604,7 +3602,7 @@ PHP_FUNCTION(stats_skew)
 /* }}} */
 
 /* {{{ proto float stats_kurtosis(array a)
-    Computes the kurtosis of the data in the array */
+	Computes the kurtosis of the data in the array */
 PHP_FUNCTION(stats_kurtosis)
 {
 	zval *arr;
@@ -3644,7 +3642,7 @@ PHP_FUNCTION(stats_kurtosis)
 
 
 /* {{{ proto float stats_covariance(array a, array b)
-    Computes the covariance of two data sets */
+	Computes the covariance of two data sets */
 PHP_FUNCTION(stats_covariance)
 {
 	zval *arr_1, *arr_2;
diff --git a/php_stats.h b/php_stats.h
index af449b3..10a9b22 100644
--- a/php_stats.h
+++ b/php_stats.h
@@ -16,8 +16,6 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id$ */
-
 #ifndef PHP_STATS_H
 #define PHP_STATS_H
 
@@ -65,7 +63,7 @@ PHP_FUNCTION(stats_rand_gen_exponential);
 PHP_FUNCTION(stats_rand_gen_f);
 PHP_FUNCTION(stats_rand_gen_gamma);
 PHP_FUNCTION(stats_rand_gen_noncentral_chisquare);
-PHP_FUNCTION(stats_rand_gen_noncenral_f);
+PHP_FUNCTION(stats_rand_gen_noncentral_f);
 PHP_FUNCTION(stats_rand_gen_normal);
 PHP_FUNCTION(stats_rand_phrase_to_seeds);
 PHP_FUNCTION(stats_rand_ibinomial);
diff --git a/tests/stats_rand_gen_noncenral_f.phpt b/tests/stats_rand_gen_noncenral_f.phpt
deleted file mode 100644
index c0bb6e8..0000000
--- a/tests/stats_rand_gen_noncenral_f.phpt
+++ /dev/null
@@ -1,26 +0,0 @@
---TEST--
-stats_rand_gen_noncenral_f()
---FILE--
-<?php
-var_dump(is_float(stats_rand_gen_noncenral_f(2, 3, 4)));
-
-// error cases
-var_dump(stats_rand_gen_noncenral_f(0.9, 3, 4));    // dfn < 1
-var_dump(stats_rand_gen_noncenral_f(2, -0.1, 4));   // dfd < 0
-var_dump(stats_rand_gen_noncenral_f(2, 0, 4));      // dfd == 0
-var_dump(stats_rand_gen_noncenral_f(2, 3, -0.1));   // xnonc < 0
-?>
---EXPECTF--
-bool(true)
-
-Warning: stats_rand_gen_noncenral_f(): Either (1) Numerator df < 1.0 or (2) Denominator df <= 0.0 or (3) Noncentrality parameter < 0.0. dfn:      9.000000E-1  dfd:      3.000000E+0  xnonc:      4.000000E+0 in %s on line %d
-bool(false)
-
-Warning: stats_rand_gen_noncenral_f(): Either (1) Numerator df < 1.0 or (2) Denominator df <= 0.0 or (3) Noncentrality parameter < 0.0. dfn:      2.000000E+0  dfd:     -1.000000E-1  xnonc:      4.000000E+0 in %s on line %d
-bool(false)
-
-Warning: stats_rand_gen_noncenral_f(): Either (1) Numerator df < 1.0 or (2) Denominator df <= 0.0 or (3) Noncentrality parameter < 0.0. dfn:      2.000000E+0  dfd:      0.000000E+0  xnonc:      4.000000E+0 in %s on line %d
-bool(false)
-
-Warning: stats_rand_gen_noncenral_f(): Either (1) Numerator df < 1.0 or (2) Denominator df <= 0.0 or (3) Noncentrality parameter < 0.0. dfn:      2.000000E+0  dfd:      3.000000E+0  xnonc:     -1.000000E-1 in %s on line %d
-bool(false)
diff --git a/tests/stats_rand_gen_noncentral_f.phpt b/tests/stats_rand_gen_noncentral_f.phpt
new file mode 100644
index 0000000..39b846a
--- /dev/null
+++ b/tests/stats_rand_gen_noncentral_f.phpt
@@ -0,0 +1,26 @@
+--TEST--
+stats_rand_gen_noncentral_f()
+--FILE--
+<?php
+var_dump(is_float(stats_rand_gen_noncentral_f(2, 3, 4)));
+
+// error cases
+var_dump(stats_rand_gen_noncentral_f(0.9, 3, 4));    // dfn < 1
+var_dump(stats_rand_gen_noncentral_f(2, -0.1, 4));   // dfd < 0
+var_dump(stats_rand_gen_noncentral_f(2, 0, 4));      // dfd == 0
+var_dump(stats_rand_gen_noncentral_f(2, 3, -0.1));   // xnonc < 0
+?>
+--EXPECTF--
+bool(true)
+
+Warning: stats_rand_gen_noncentral_f(): Either (1) Numerator df < 1.0 or (2) Denominator df <= 0.0 or (3) Noncentrality parameter < 0.0. dfn:      9.000000E-1  dfd:      3.000000E+0  xnonc:      4.000000E+0 in %s on line %d
+bool(false)
+
+Warning: stats_rand_gen_noncentral_f(): Either (1) Numerator df < 1.0 or (2) Denominator df <= 0.0 or (3) Noncentrality parameter < 0.0. dfn:      2.000000E+0  dfd:     -1.000000E-1  xnonc:      4.000000E+0 in %s on line %d
+bool(false)
+
+Warning: stats_rand_gen_noncentral_f(): Either (1) Numerator df < 1.0 or (2) Denominator df <= 0.0 or (3) Noncentrality parameter < 0.0. dfn:      2.000000E+0  dfd:      0.000000E+0  xnonc:      4.000000E+0 in %s on line %d
+bool(false)
+
+Warning: stats_rand_gen_noncentral_f(): Either (1) Numerator df < 1.0 or (2) Denominator df <= 0.0 or (3) Noncentrality parameter < 0.0. dfn:      2.000000E+0  dfd:      3.000000E+0  xnonc:     -1.000000E-1 in %s on line %d
+bool(false)