Jump to content

quartiles function?


regent

Recommended Posts

I took the example provided here:

 

http://www.vias.org/tmdatanaleng/cc_quartile.html

 

You could easily turn this into a function....

 

$values = array(-20, -4, -1, -1, 0, 1, 2, 3, 4, 4, 7, 7, 8, 11, 11, 12, 12, 15, 18, 22);
$count = count($values);

$first = round( .25 * ( $count + 1 ) ) - 1;
$second = ($count % 2 == 0) ? ($values[($count / 2) - 1] + $values[$count / 2]) / 2 : $second = $values[($count + 1) / 2];
$third = round( .75 * ( $count + 1 ) ) - 1;


echo "<pre>" . print_r($values, true) . "
first = $first<br />
values[first] = $values[$first]<br />
<br />
second = $second<br />
<br />
third = $third<br />
values[third] = $values[$third]";

Link to comment
https://forums.phpfreaks.com/topic/44573-quartiles-function/#findComment-216491
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.