src/Phpml/DimensionReduction/PCA.php 1 location
|
@@ 118-121 (lines=4) @@
|
115 |
|
{ |
116 |
|
// Calculate means for each dimension |
117 |
|
$this->means = []; |
118 |
|
for ($i=0; $i < $n; $i++) { |
119 |
|
$column = array_column($data, $i); |
120 |
|
$this->means[] = Mean::arithmetic($column); |
121 |
|
} |
122 |
|
} |
123 |
|
|
124 |
|
/** |
src/Phpml/Math/Statistic/Covariance.php 1 location
|
@@ 136-138 (lines=3) @@
|
133 |
|
|
134 |
|
if ($means === null) { |
135 |
|
$means = []; |
136 |
|
for ($i=0; $i < $n; $i++) { |
137 |
|
$means[] = Mean::arithmetic(array_column($data, $i)); |
138 |
|
} |
139 |
|
} |
140 |
|
|
141 |
|
$cov = []; |