Re: Calculating Percentile

[email protected] (Rob Dixon)
Newsgroups perl.beginners
Message-ID <[email protected]>
Rodrick Brown wrote:
>
> I'm having a hardtime coming up with the correct formula for calculating
> percentile on an array of random intergers. Anyone care to assist?
> 
> #!/usr/bin/perl -w
> use strict;
> my @numbers = (10.22,20.33,22.3,11.3,12.4,8.3,10.4);
> sub calc {
>   my ($p,$n) = @_;
>   return $p/100 * ($n + 1);
> }
> 
> printf "Percentile: %s\n", calc($_,$#numbers) for qw/25 50 75 90 95 99/;

If you show us which of the many possible ways you want to use to calculate
percentiles then we can help you code it in Perl.

Rob
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.