Skip to content

Commit 353fdee

Browse files
committed
Minor style improvements.
1 parent a215c7f commit 353fdee

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

src/Statistics/RandomVariable.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,16 @@ public static function centralMoment(array $X, int $n): float
6464
throw new Exception\BadDataException('Cannot find the central moment of an empty list of numbers');
6565
}
6666

67-
$μ = Average::mean($X);
68-
$∑⟮xᵢ − μ⟯ⁿ = \array_sum(\array_map(
67+
$μ = Average::mean($X);
68+
$∑⟮xᵢμ⟯ⁿ = \array_sum(\array_map(
6969
function ($xᵢ) use ($μ, $n) {
7070
return \pow(($xᵢ - $μ), $n);
7171
},
7272
$X
7373
));
7474
$N = \count($X);
7575

76-
return $∑⟮xᵢ − μ⟯ⁿ / $N;
76+
return $∑⟮xᵢμ⟯ⁿ / $N;
7777
}
7878

7979
/**
@@ -145,17 +145,17 @@ public static function sampleSkewness(array $X): float
145145
throw new Exception\BadDataException('Cannot find the sample skewness of less than three numbers');
146146
}
147147

148-
$μ₃ = self::centralMoment($X, 3);
149-
$μ₂ = self::centralMoment($X, 2);
148+
$μ₃ = self::centralMoment($X, 3);
149+
$μ₂ = self::centralMoment($X, 2);
150150

151151
$μ₂³′² = \pow($μ₂, 3 / 2);
152152
if ($μ₂³′² == 0) {
153153
return \NAN; // Prevents division by zero in μ₃ / μ₂³′² equation
154154
}
155155

156-
$√⟮n⟮n − 1⟯⟯ = \sqrt($n * ($n - 1));
156+
$√⟮n⟮n1⟯⟯ = \sqrt($n * ($n - 1));
157157

158-
return ($μ₃ / $μ₂³′²) * ( $√⟮n⟮n − 1⟯⟯ / ($n - 2) );
158+
return ($μ₃ / $μ₂³′²) * ( $√⟮n⟮n1⟯⟯ / ($n - 2) );
159159
}
160160

161161
/**
@@ -187,20 +187,20 @@ public static function alternativeSkewness(array $X): float
187187
}
188188

189189
$μ = Average::mean($X);
190-
$∑⟮xᵢ − μ⟯³ = \array_sum(\array_map(
190+
$∑⟮xᵢμ⟯³ = \array_sum(\array_map(
191191
function ($xᵢ) use ($μ) {
192192
return \pow(($xᵢ - $μ), 3);
193193
},
194194
$X
195195
));
196196
$σ³ = \pow(Descriptive::standardDeviation($X, Descriptive::SAMPLE), 3);
197197

198-
$⟮σ³ × ⟮N − 1⟯⟯ = ($σ³ * ($N - 1));
199-
if ($⟮σ³ × ⟮N − 1⟯⟯ == 0) {
198+
$⟮σ³×⟮N−1⟯⟯ = ($σ³ * ($N - 1));
199+
if ($⟮σ³×⟮N−1⟯⟯ == 0) {
200200
return \NAN;
201201
}
202202

203-
return $∑⟮xᵢ − μ⟯³ / $⟮σ³ × ⟮N − 1⟯⟯;
203+
return $∑⟮xᵢμ⟯³ / $⟮σ³×⟮N−1⟯⟯;
204204
}
205205

206206
/**
@@ -260,10 +260,10 @@ public static function ses(int $n): float
260260
throw new Exception\BadDataException("SES requires a dataset of n > 2. N of $n given.");
261261
}
262262

263-
$6n⟮n − 1 = 6 * $n * ($n - 1);
264-
$⟮n − 2⟯⟮n + 1⟯⟮n + 2 = ($n - 2) * ($n + 1) * ($n + 3);
263+
$6n⟮n−1⟯ = 6 * $n * ($n - 1);
264+
$⟮n2⟯⟮n1⟯⟮n+3 = ($n - 2) * ($n + 1) * ($n + 3);
265265

266-
return \sqrt($6n⟮n − 1⟯ / $⟮n − 2⟯⟮n + 1⟯⟮n + 2);
266+
return \sqrt($6n⟮n1⟯ / $⟮n2⟯⟮n1⟯⟮n+3);
267267
}
268268

269269
/**
@@ -328,15 +328,15 @@ public static function sampleKurtosis(array $X): float
328328
public static function populationKurtosis(array $X): float
329329
{
330330
if (\count($X) < 4) {
331-
throw new Exception\BadDataException('Cannot find the kurtosis of an empty list of numbers');
331+
throw new Exception\BadDataException('Cannot find the kurtosis of fewer than 4 numbers');
332332
}
333333

334334
$g₂ = self::sampleKurtosis($X);
335335

336336
$n = \count($X);
337-
$⟮n + 1⟯g₂ + 6 = ($n + 1) * $g₂ + 6;
337+
$⟮n1⟯g₂6 = ($n + 1) * $g₂ + 6;
338338

339-
return ($⟮n + 1⟯g₂ + 6 * ($n - 1)) / (($n - 2) * ($n - 3));
339+
return ($⟮n1⟯g₂6 * ($n - 1)) / (($n - 2) * ($n - 3));
340340
}
341341

342342
/**
@@ -443,11 +443,11 @@ public static function sek(int $n): float
443443
throw new Exception\BadDataException("SEK requires a dataset of n > 3. N of $n given.");
444444
}
445445

446-
$2⟮SES⟯ = 2 * self::ses($n);
447-
$⟮n² − 1 = $n ** 2 - 1;
448-
$⟮n − 3⟯⟮n + 5 = ($n - 3) * ($n + 5);
446+
$2⟮SES⟯ = 2 * self::ses($n);
447+
$⟮n²−1⟯ = $n ** 2 - 1;
448+
$⟮n3⟯⟮n5⟯ = ($n - 3) * ($n + 5);
449449

450-
return $2⟮SES⟯ * \sqrt($⟮n² − 1⟯ / $⟮n − 3⟯⟮n + 5);
450+
return $2⟮SES⟯ * \sqrt($⟮n²1⟯ / $⟮n3⟯⟮n5⟯);
451451
}
452452

453453
/**
@@ -580,14 +580,14 @@ public static function sumOfSquaresDeviations(array $numbers): float
580580
throw new Exception\BadDataException('Cannot find the sum of squares deviations of an empty list of numbers');
581581
}
582582

583-
$μ = Average::mean($numbers);
584-
$∑⟮xᵢ − μ⟯² = \array_sum(\array_map(
583+
$μ = Average::mean($numbers);
584+
$∑⟮xᵢμ⟯² = \array_sum(\array_map(
585585
function ($xᵢ) use ($μ) {
586586
return \pow(($xᵢ - $μ), 2);
587587
},
588588
$numbers
589589
));
590590

591-
return $∑⟮xᵢ − μ⟯²;
591+
return $∑⟮xᵢμ⟯²;
592592
}
593593
}

0 commit comments

Comments
 (0)