Calculating Percentile

[email protected] ("Rodrick Brown")
Newsgroups perl.beginners
Message-ID <[email protected]>
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/;
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.