Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/undo-ransomware/ransomware_detection.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias <ilovemilk@wusa.io>2019-05-17 18:13:21 +0300
committerMatthias <ilovemilk@wusa.io>2019-05-17 18:13:21 +0300
commit5551db8c80f440554676c0d37b82b24e465773a0 (patch)
treece664f6371c77ab3565d5ce8b42ed94c78ee8838 /tests/Unit
parentfb1aa4c89f889a47d446ba3f12f19658be5f9cf3 (diff)
test stream standard deviation calculation
Diffstat (limited to 'tests/Unit')
-rw-r--r--tests/Unit/Entropy/EntropyTest.php7
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);
}
}