35 define(
"NAN_HANDLING_REMOVE", 0);
36 define(
"NAN_HANDLING_ZERO", 1);
66 $this->stat_data = array();
128 if (
count($this->stat_data))
130 $min =
min($this->stat_data);
147 if (
count($this->stat_data))
149 $max =
max($this->stat_data);
165 return count($this->stat_data);
177 if (
count($this->stat_data))
180 foreach ($this->stat_data as $value)
182 $sum_n += pow((
double)$value, (
double)
$n);
195 return $this->
sum_n(1);
206 return $this->
sum_n(2);
218 if (
count($this->stat_data))
220 if ($this->
min() === 0)
225 foreach ($this->stat_data as $value)
227 $prod_n *= pow((
double)$value, (
double)
$n);
257 $count = $this->
count();
262 return (
double)($sum/$count);
278 if (($prod ===
false) or ($prod === 0))
282 $count = $this->
count();
287 return pow((
double)$prod, (
double)(1/$count));
299 if (($min ===
false) or ($min === 0))
303 $count = $this->
count();
309 foreach ($this->stat_data as $value)
324 if (
count($this->stat_data))
327 $count = $this->
count();
328 if ((
count($this->stat_data) % 2) == 0)
330 $median = ($this->stat_data[($count / 2) - 1] + $this->stat_data[($count / 2)]) / 2;
334 $median = $this->stat_data[(($count + 1) / 2) - 1];
348 if (!is_numeric($value))
352 $rank = array_search($value, $this->stat_data);
355 $rank = $this->
count() - $rank;
372 $count = $this->
count();
378 if (($count % 2) == 0)
380 $rank_median = ($count + 1) / 2;
384 $rank_median = ($count + 1) / 2;
397 $count = $this->
count();
402 $nprod = (
$n/100)*$count;
403 if (intval($nprod) == $nprod)
408 return $this->stat_data[$k];
410 else if ($k == $count)
412 return $this->stat_data[$k-1];
416 return ($this->stat_data[$k-1] + $this->stat_data[$k])/2;
422 return $this->stat_data[$k-1];
437 foreach ($this->stat_data as $key => $value)
439 if (!is_numeric($value)) {
440 switch ($this->nan_handling) {
442 unset($this->stat_data[$key]);
445 $this->stat_data[$key] = 0;
452 sort($this->stat_data);