stats_stat_percentile
(PECL stats >= 1.0.0)
stats_stat_percentile — Не документирована
Описание
float stats_stat_percentile
( float
$df
, float $xnonc
)Внимание
К настоящему времени эта функция еще не была документирована; для ознакомления доступен только список аргументов.
Список параметров
-
df
-
-
xnonc
-
Возвращаемые значения
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Математические расширения
- Статистика
- stats_absolute_deviation
- stats_cdf_beta
- stats_cdf_binomial
- stats_cdf_cauchy
- stats_cdf_chisquare
- stats_cdf_exponential
- stats_cdf_f
- stats_cdf_gamma
- stats_cdf_laplace
- stats_cdf_logistic
- stats_cdf_negative_binomial
- stats_cdf_noncentral_chisquare
- stats_cdf_noncentral_f
- stats_cdf_poisson
- stats_cdf_t
- stats_cdf_uniform
- stats_cdf_weibull
- stats_covariance
- stats_den_uniform
- stats_dens_beta
- stats_dens_cauchy
- stats_dens_chisquare
- stats_dens_exponential
- stats_dens_f
- stats_dens_gamma
- stats_dens_laplace
- stats_dens_logistic
- stats_dens_negative_binomial
- stats_dens_normal
- stats_dens_pmf_binomial
- stats_dens_pmf_hypergeometric
- stats_dens_pmf_poisson
- stats_dens_t
- stats_dens_weibull
- stats_harmonic_mean
- stats_kurtosis
- stats_rand_gen_beta
- stats_rand_gen_chisquare
- stats_rand_gen_exponential
- stats_rand_gen_f
- stats_rand_gen_funiform
- stats_rand_gen_gamma
- stats_rand_gen_ibinomial_negative
- stats_rand_gen_ibinomial
- stats_rand_gen_int
- stats_rand_gen_ipoisson
- stats_rand_gen_iuniform
- stats_rand_gen_noncenral_chisquare
- stats_rand_gen_noncentral_f
- stats_rand_gen_noncentral_t
- stats_rand_gen_normal
- stats_rand_gen_t
- stats_rand_get_seeds
- stats_rand_phrase_to_seeds
- stats_rand_ranf
- stats_rand_setall
- stats_skew
- stats_standard_deviation
- stats_stat_binomial_coef
- stats_stat_correlation
- stats_stat_gennch
- stats_stat_independent_t
- stats_stat_innerproduct
- stats_stat_noncentral_t
- stats_stat_paired_t
- stats_stat_percentile
- stats_stat_powersum
- stats_variance
Коментарии
I have looked at the code available in the Math package for percentile. I compared the result obtained with percentile from Excel and found that it doesnt match. So i wrote my own percentile function and verified the result with the Excel's percentile.
For those of you who need the percentile calculation of Excel in php..
<?php
function mypercentile($data,$percentile){
if( 0 < $percentile && $percentile < 1 ) {
$p = $percentile;
}else if( 1 < $percentile && $percentile <= 100 ) {
$p = $percentile * .01;
}else {
return "";
}
$count = count($data);
$allindex = ($count-1)*$p;
$intvalindex = intval($allindex);
$floatval = $allindex - $intvalindex;
sort($data);
if(!is_float($floatval)){
$result = $data[$intvalindex];
}else {
if($count > $intvalindex+1)
$result = $floatval*($data[$intvalindex+1] - $data[$intvalindex]) + $data[$intvalindex];
else
$result = $data[$intvalindex];
}
return $result;
}
?>
The above code may not be elegant.. but it solves my problem..
yuvaraj
If you are looking to infer the percentile from a z-score, you can use this function.
It's far from precise but does the job on most circumstances.
The error function ( erf() )is based on the approximation on wikipedia:
http://en.wikipedia.org/wiki/Error_function
<?php
function erf($x)
{
$pi = 3.1415927;
$a = (8*($pi - 3))/(3*$pi*(4 - $pi));
$x2 = $x * $x;
$ax2 = $a * $x2;
$num = (4/$pi) + $ax2;
$denom = 1 + $ax2;
$inner = (-$x2)*$num/$denom;
$erf2 = 1 - exp($inner);
return sqrt($erf2);
}
function cdf($n)
{
if($n < 0)
{
return (1 - erf($n / sqrt(2)))/2;
}
else
{
return (1 + erf($n / sqrt(2)))/2;
}
}
// EXAMPLE
$sample = 90;
$avg = 75;
$stddev = 12;
$zscore = ($sample - $avg) / $stddev;
print 'Percentile: ' . cdf($zscore) * 100 . "\n";
?>
Where $n is the z-score
The function cdf() returns the approximed cumulative standard normal distribution ([0..1])
[EDIT BY danbrown AT php DOT net: Contains a bugfix provided by (Ed) on 24-FEB-2010 which fixes the definition of $a in erf() with the note that it is "out by a factor of -1" in the original code.]