Mariusz Muszyński 7 anos atrás
pai
commit
0036595728
1 arquivos alterados com 6 adições e 2 exclusões
  1. 6 2
      SE/se-lib/Benford.php

+ 6 - 2
SE/se-lib/Benford.php

@@ -45,7 +45,9 @@ class Benford {
 			$this->benford['firstStep'][$s[0]]['keys'][] = $k;
 		}
 
-		foreach ($this->benford['firstStep'] as $k => $v) {
+		for ($k = 1; $k <= 9; $k++) {
+			if (!isset($this->benford['firstStep'][$k])) $this->benford['firstStep'][$k]['keys'] = [];
+			$v = $this->benford['firstStep'][$k];
 			$this->benford['firstStep'][$k]['count'] = count($v['keys']);
 			$this->benford['firstStep'][$k]['value'] = count($v['keys']) / count($this->array);
 			$this->benford['firstStep'][$k]['norm'] = self::benford($k);
@@ -77,7 +79,9 @@ class Benford {
 			$this->benford['secondStep'][$a][$s[1]]['keys'][] = $k;
 		}
 
-		foreach ($this->benford['secondStep'][$a] as $k => $v) {
+		for ($k = 0; $k <= 9; $k++) {
+			if (!isset($this->benford['secondStep'][$a][$k])) $this->benford['secondStep'][$a][$k]['keys'] = [];
+			$v = $this->benford['secondStep'][$a][$k];
 			$this->benford['secondStep'][$a][$k]['count'] = count($v['keys']);
 			$this->benford['secondStep'][$a][$k]['value'] = count($v['keys']) / count($this->array);
 			$this->benford['secondStep'][$a][$k]['norm'] = self::benford($a * 10 + $k);