Menu

#1 correct quartile (I think)

open
nobody
None
5
2002-11-20
2002-11-20
Anonymous
No

function quartile ($numarr, $frac) {
frac = doubleval($frac);
sort($numarr);
$n = count($numarr);
// for ($j=0;$j<$n ;$j++ ) {
// echo $numarr[$j].";";
// }
// echo "<BR>".$n . "=n<BR>";
$i = floor(($n - 1)*$frac);
// echo $i."=i<BR>";
$d = ($n - 1)*$frac - floor(($n -1)*$frac);
// echo $d ."=d<BR>";
$quartile = (1 - $d)*$numarr[$i] + $d*$numarr[($i + 1)];
//echo $n." ".$i." ".$d." ".$frac."\n<BR>";
return $quartile;
}
szilard@int.com

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.