diff options
author | Matthias <ilovemilk@wusa.io> | 2019-05-17 18:13:21 +0300 |
---|---|---|
committer | Matthias <ilovemilk@wusa.io> | 2019-05-17 18:13:21 +0300 |
commit | 5551db8c80f440554676c0d37b82b24e465773a0 (patch) | |
tree | ce664f6371c77ab3565d5ce8b42ed94c78ee8838 /tests/Unit | |
parent | fb1aa4c89f889a47d446ba3f12f19658be5f9cf3 (diff) |
test stream standard deviation calculation
Diffstat (limited to 'tests/Unit')
-rw-r--r-- | tests/Unit/Entropy/EntropyTest.php | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/Unit/Entropy/EntropyTest.php b/tests/Unit/Entropy/EntropyTest.php index d56fcc8..0b3266f 100644 --- a/tests/Unit/Entropy/EntropyTest.php +++ b/tests/Unit/Entropy/EntropyTest.php @@ -77,5 +77,12 @@ class EntropyTest extends TestCase public function testSd($data, $sd) { $this->assertEquals(number_format($this->invokePrivate($this->entropy, 'sd', [$data]), 6), $sd); + $sum = 0.0, $mean = 0.0, $standardDeviation = 0.0; + foreach($data as $key => $value) { + $sum = $sum + pow($value, 2); + $mean = $this->invokePrivate($this->entropy, 'streamMean', [$mean, $value, $key + 1]); + $standardDeviation = $this->invokePrivate($this->entropy, 'streamStandardDeviation', [$key + 1, $sum, $mean]); + } + $this->assertEquals(number_format($standardDeviation, 6), $sd); } } |