Ratt::beräkna_fannrätt()   A
last analyzed

Complexity

Conditions 4
Paths 5

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
cc 4
eloc 12
nc 5
nop 0
dl 0
loc 18
ccs 0
cts 13
cp 0
crap 20
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Klass Ratt.
5
 * @author Niklas Dougherty
6
 */
7
8
declare(strict_types=1);
9
10
namespace Tips\Moduler\FANNGenerera;
11
12
/**
13
 * Klass Ratt.
14
 */
15
class Ratt extends Parametrar {
16
	/**
17
	 * Beräkna fördelning av antal rätt för FANN.
18
	 * @return int[]
19
	 */
20
	protected function beräkna_fannrätt(): array {
21
		$fannrätt = [];
22
23
		foreach ($this->oddssannolikheter as $i => $oddssannolikheter) {
24
			$rådata = [];
25
			foreach ($oddssannolikheter as $j => $odds) {
26
				$streck = $this->strecksannolikheter[$i][$j];
27
				$res = fann_run($this->fann->fann, [$odds[0], $streck[0], $odds[1], $streck[1], $odds[2], $streck[2]]);
28
				$rådata[] = $res[0];
29
			}
30
31
			$utdata = $this->fann->beräkna_utdata($rådata, $this->fann->limiter);
32
			$antal_rätt = antal_rätt($utdata, $this->tipsrader[$i]);
33
			$fannrätt[$antal_rätt] = isset($fannrätt[$antal_rätt]) ? $fannrätt[$antal_rätt] + 1 : 1;
34
		}
35
36
		krsort($fannrätt);
37
		return $fannrätt;
38
	}
39
}
40