@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $cumulative = Numbers::makeZero(); |
80 | 80 | |
81 | - for ($i = 0;$x->isGreaterThanOrEqualTo($i);$i++) { |
|
81 | + for ($i = 0; $x->isGreaterThanOrEqualTo($i); $i++) { |
|
82 | 82 | $cumulative = $cumulative->add($this->pmf($i)); |
83 | 83 | } |
84 | 84 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | $cumulative = Numbers::makeZero(); |
147 | 147 | |
148 | - for (;$larger->isGreaterThanOrEqualTo($smaller);$smaller->add(1)) { |
|
148 | + for (;$larger->isGreaterThanOrEqualTo($smaller); $smaller->add(1)) { |
|
149 | 149 | $cumulative = $cumulative->add($this->pmf($smaller)); |
150 | 150 | } |
151 | 151 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | |
228 | 228 | while (true) { |
229 | 229 | /** @var ImmutableDecimal $u */ |
230 | - $u = PolyfillProvider::randomInt(0, PHP_INT_MAX) / PHP_INT_MAX; |
|
230 | + $u = PolyfillProvider::randomInt(0, PHP_INT_MAX)/PHP_INT_MAX; |
|
231 | 231 | /** @var ImmutableDecimal $x */ |
232 | 232 | $x = $alpha->subtract($one->subtract($u)->divide($u)->ln(20)->divide($beta)); |
233 | 233 | /** @var ImmutableDecimal $n */ |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | do { |
280 | 280 | $k = $k->add(1); |
281 | 281 | /** @var ImmutableDecimal $u */ |
282 | - $u = PolyfillProvider::randomInt(0, PHP_INT_MAX) / PHP_INT_MAX; |
|
282 | + $u = PolyfillProvider::randomInt(0, PHP_INT_MAX)/PHP_INT_MAX; |
|
283 | 283 | $p = $p->multiply($u); |
284 | 284 | } while ($p->isGreaterThan($L)); |
285 | 285 |
@@ -25,6 +25,6 @@ |
||
25 | 25 | return $sample; |
26 | 26 | } |
27 | 27 | |
28 | - abstract public function rangeRandom($min = 0, $max = PHP_INT_MAX, int $maxIterations = 20): ImmutableDecimal; |
|
28 | + abstract public function rangeRandom($min = 0, $max = PHP_INT_MAX, int $maxIterations = 20): ImmutableDecimal; |
|
29 | 29 | |
30 | 30 | } |
31 | 31 | \ No newline at end of file |
@@ -18,7 +18,7 @@ |
||
18 | 18 | { |
19 | 19 | $sample = new NumberCollection(); |
20 | 20 | |
21 | - for ($i = 1;$i < $sampleSize;$i++) { |
|
21 | + for ($i = 1; $i < $sampleSize; $i++) { |
|
22 | 22 | $sample->push($this->random()); |
23 | 23 | } |
24 | 24 |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | ->multiply($e->pow($eExponent)) |
50 | 50 | ->multiply(SeriesProvider::maclaurinSeries( |
51 | 51 | $x, |
52 | - function ($n) { |
|
52 | + function($n) { |
|
53 | 53 | return Numbers::makeOne(); |
54 | 54 | }, |
55 | - function ($n) { |
|
55 | + function($n) { |
|
56 | 56 | return SequenceProvider::nthOddNumber($n); |
57 | 57 | }, |
58 | - function ($n) { |
|
58 | + function($n) { |
|
59 | 59 | return SequenceProvider::nthOddNumber($n)->doubleFactorial(); |
60 | 60 | }, |
61 | 61 | 0, |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $x = Numbers::makeOrDont(Numbers::IMMUTABLE, $x); |
96 | 96 | |
97 | 97 | $scale = $x->getScale(); |
98 | - $internalScale = $scale + 2; |
|
98 | + $internalScale = $scale+2; |
|
99 | 99 | |
100 | 100 | $answer = Numbers::makeOne($internalScale); |
101 | 101 | $pi = Numbers::makePi($internalScale); |
@@ -105,15 +105,15 @@ discard block |
||
105 | 105 | $answer = $answer->multiply( |
106 | 106 | SeriesProvider::maclaurinSeries( |
107 | 107 | $x, |
108 | - function ($n) { |
|
108 | + function($n) { |
|
109 | 109 | $negOne = Numbers::make(Numbers::IMMUTABLE, -1); |
110 | 110 | |
111 | 111 | return $negOne->pow($n); |
112 | 112 | }, |
113 | - function ($n) { |
|
113 | + function($n) { |
|
114 | 114 | return SequenceProvider::nthOddNumber($n); |
115 | 115 | }, |
116 | - function ($n) { |
|
116 | + function($n) { |
|
117 | 117 | $n = Numbers::makeOrDont(Numbers::IMMUTABLE, $n); |
118 | 118 | |
119 | 119 | return $n->factorial()->multiply(SequenceProvider::nthOddNumber($n->asInt())); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $p = Numbers::makeOrDont(Numbers::IMMUTABLE, $p); |
141 | 141 | |
142 | 142 | $scale = $scale ?? $p->getScale(); |
143 | - $internalScale = $scale + 2; |
|
143 | + $internalScale = $scale+2; |
|
144 | 144 | |
145 | 145 | $two = Numbers::make(Numbers::IMMUTABLE, 2, $internalScale); |
146 | 146 | $invErfArg = $two->multiply($p)->subtract(1); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | public static function inverseErrorCoefficients(int $termIndex): ImmutableFraction |
186 | 186 | { |
187 | 187 | |
188 | - $terms =& static::$inverseErrorCoefs; |
|
188 | + $terms = & static::$inverseErrorCoefs; |
|
189 | 189 | |
190 | 190 | if (is_null(static::$inverseErrorCoefs)) { |
191 | 191 | $terms = new Vector(); |
@@ -199,13 +199,13 @@ discard block |
||
199 | 199 | |
200 | 200 | $nextTerm = $terms->count(); |
201 | 201 | |
202 | - for ($k = $nextTerm;$k <= $termIndex;$k++) { |
|
202 | + for ($k = $nextTerm; $k <= $termIndex; $k++) { |
|
203 | 203 | $termValue = new ImmutableFraction(new ImmutableDecimal('0'), new ImmutableDecimal('1')); |
204 | - for ($m = 0;$m <= ($k - 1);$m++) { |
|
204 | + for ($m = 0; $m <= ($k-1); $m++) { |
|
205 | 205 | $part1 = $terms->get($m); |
206 | - $part2 = $terms->get($k - 1 - $m); |
|
206 | + $part2 = $terms->get($k-1-$m); |
|
207 | 207 | $part3 = $part1->multiply($part2); |
208 | - $part4 = ($m + 1)*($m*2 + 1); |
|
208 | + $part4 = ($m+1)*($m*2+1); |
|
209 | 209 | $part5 = $part3->divide($part4); |
210 | 210 | $termValue = $termValue->add($part5); |
211 | 211 | } |
@@ -234,23 +234,23 @@ discard block |
||
234 | 234 | $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $z); |
235 | 235 | |
236 | 236 | $scale = $scale ?? $z->getScale(); |
237 | - $internalScale = $scale + 1; |
|
237 | + $internalScale = $scale+1; |
|
238 | 238 | |
239 | 239 | $pi = Numbers::makePi($internalScale); |
240 | 240 | |
241 | 241 | $answer = SeriesProvider::maclaurinSeries( |
242 | 242 | $z, |
243 | - static function ($n) use ($pi) { |
|
243 | + static function($n) use ($pi) { |
|
244 | 244 | if ($n > 0) { |
245 | 245 | return $pi->pow($n)->multiply(StatsProvider::inverseErrorCoefficients($n)); |
246 | 246 | } |
247 | 247 | |
248 | 248 | return Numbers::makeOne(); |
249 | 249 | }, |
250 | - static function ($n) { |
|
250 | + static function($n) { |
|
251 | 251 | return SequenceProvider::nthOddNumber($n); |
252 | 252 | }, |
253 | - static function ($n) { |
|
253 | + static function($n) { |
|
254 | 254 | if ($n > 0) { |
255 | 255 | $extra = Numbers::make(Numbers::IMMUTABLE, 2)->pow(SequenceProvider::nthEvenNumber($n)); |
256 | 256 | } else { |