diff options
Diffstat (limited to 'lib/Entropy/Entropy.php')
-rw-r--r-- | lib/Entropy/Entropy.php | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Entropy/Entropy.php b/lib/Entropy/Entropy.php index 36fde3c..798db8b 100644 --- a/lib/Entropy/Entropy.php +++ b/lib/Entropy/Entropy.php @@ -57,6 +57,10 @@ class Entropy return $entropy; } + public function streamStandardDeviation($n, $sum, $mean) { + return sqrt((1 / $n) * $sum - pow($mean, 2)); + } + /** * Calculates the standard deviation. * @@ -83,4 +87,14 @@ class Entropy return 0.0; } + + public function streamMean($oldMean, $value, $step) { + $mean = 0; + if ($step === 1) { + $mean = (($step - 1) / $step) + ($value / $step); + } else { + $mean = $oldMean * (($step - 1) / $step) + ($value / $step); + } + return $mean; + } } |