15 define(
"NAN_HANDLING_REMOVE", 0);
16 define(
"NAN_HANDLING_ZERO", 1);
46 $this->stat_data = array();
108 if (
count($this->stat_data))
110 $min =
min($this->stat_data);
127 if (
count($this->stat_data))
129 $max =
max($this->stat_data);
145 return count($this->stat_data);
157 if (
count($this->stat_data))
160 foreach ($this->stat_data as $value)
162 $sum_n += pow((
double)$value, (
double)
$n);
175 return $this->
sum_n(1);
186 return $this->
sum_n(2);
198 if (
count($this->stat_data))
200 if ($this->
min() === 0)
205 foreach ($this->stat_data as $value)
207 $prod_n *= pow((
double)$value, (
double)
$n);
237 $count = $this->
count();
242 return (
double)($sum/$count);
258 if (($prod ===
false) or ($prod === 0))
262 $count = $this->
count();
267 return pow((
double)$prod, (
double)(1/$count));
279 if (($min ===
false) or ($min === 0))
283 $count = $this->
count();
289 foreach ($this->stat_data as $value)
304 if (
count($this->stat_data))
307 $count = $this->
count();
308 if ((
count($this->stat_data) % 2) == 0)
310 $median = ($this->stat_data[($count / 2) - 1] + $this->stat_data[($count / 2)]) / 2;
314 $median = $this->stat_data[(($count + 1) / 2) - 1];
328 if (!is_numeric($value))
332 $rank = array_search($value, $this->stat_data);
335 $rank = $this->
count() - $rank;
352 $count = $this->
count();
358 if (($count % 2) == 0)
360 $rank_median = ($count + 1) / 2;
364 $rank_median = ($count + 1) / 2;
377 $count = $this->
count();
382 $nprod = (
$n/100)*$count;
383 if (intval($nprod) == $nprod)
388 return $this->stat_data[$k];
390 else if ($k == $count)
392 return $this->stat_data[$k-1];
396 return ($this->stat_data[$k-1] + $this->stat_data[$k])/2;
402 return $this->stat_data[$k-1];
417 foreach ($this->stat_data as
$key => $value)
419 if (!is_numeric($value)) {
420 switch ($this->nan_handling) {
422 unset($this->stat_data[
$key]);
425 $this->stat_data[
$key] = 0;
432 sort($this->stat_data);