Re: 95th percentile of an array.
| From: | Marc Trudel | Date: | Mon, 31 Jan 2011 01:44:31 +0000 |
| Subject: | Re: 95th percentile of an array. | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-311089@lists.php.net to get a copy of this message | ||
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@gmail.com>wrote:
> On Sat, Jan 29, 2011 at 2:28 PM, Adam Richardson <simpleshot@gmail.com>
> 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