Re: 95th percentile of an array.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Just out of curiosity, wouldnt it be better to use floor($n) instead of
round($n-0.5)?

On Sun, Jan 30, 2011 at 5:48 AM, Paul Halliday <paul.halliday@xxxxxxxxx>wrote:

> On Sat, Jan 29, 2011 at 2:28 PM, Adam Richardson <simpleshot@xxxxxxxxx>
> wrote:
> > For the nearest rank computation, you could use the following:
> >
> > $arr =
> >
> array(12,89,65,23,90,99,9,15,56,67,3,52,78,12,10,88,77,77,77,77,77,77,77);
> > sort($arr);
> > $score_representing_95th_percentile = $arr[round((95/100) * count($arr) -
> > .5)];
> > echo $score_representing_95th_percentile; // 90
> >
>
> Perfect, exactly what I was looking for.
>
> thank you.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Marc Trudel-Bélisle
*Chief Technical Officer*
www.wizcorp.jp

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux