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-- - ---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-- + +--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)