@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | ->multiply($e->pow($eExponent)) |
33 | 33 | ->multiply(SeriesProvider::maclaurinSeries( |
34 | 34 | $x, |
35 | - function ($n) { |
|
35 | + function($n) { |
|
36 | 36 | return Numbers::makeOne(); |
37 | 37 | }, |
38 | - function ($n) { |
|
38 | + function($n) { |
|
39 | 39 | return SequenceProvider::nthOddNumber($n); |
40 | 40 | }, |
41 | - function ($n) { |
|
41 | + function($n) { |
|
42 | 42 | return SequenceProvider::nthOddNumber($n)->doubleFactorial(); |
43 | 43 | } |
44 | 44 | )) |
@@ -68,15 +68,15 @@ discard block |
||
68 | 68 | $answer = $answer->multiply( |
69 | 69 | SeriesProvider::maclaurinSeries( |
70 | 70 | $x, |
71 | - function ($n) { |
|
71 | + function($n) { |
|
72 | 72 | $negOne = Numbers::make(Numbers::IMMUTABLE, -1); |
73 | 73 | |
74 | 74 | return $negOne->pow($n); |
75 | 75 | }, |
76 | - function ($n) { |
|
76 | + function($n) { |
|
77 | 77 | return SequenceProvider::nthOddNumber($n); |
78 | 78 | }, |
79 | - function ($n) { |
|
79 | + function($n) { |
|
80 | 80 | $n = Numbers::makeOrDont(Numbers::IMMUTABLE, $n); |
81 | 81 | |
82 | 82 | return $n->factorial()->multiply(SequenceProvider::nthOddNumber($n)); |
@@ -2,9 +2,9 @@ |
||
2 | 2 | |
3 | 3 | namespace Samsara\Fermat\Values; |
4 | 4 | |
5 | -use Samsara\Fermat\Numbers; |
|
6 | -use Samsara\Fermat\Types\Number; |
|
7 | -use Samsara\Fermat\Types\Base\DecimalInterface; |
|
5 | +use Samsara\Fermat\Numbers; |
|
6 | +use Samsara\Fermat\Types\Number; |
|
7 | +use Samsara\Fermat\Types\Base\DecimalInterface; |
|
8 | 8 | use Samsara\Fermat\Types\Base\NumberInterface; |
9 | 9 | |
10 | 10 | class ImmutableNumber extends Number implements NumberInterface, DecimalInterface |
@@ -10,6 +10,9 @@ |
||
10 | 10 | class ImmutableNumber extends Number implements NumberInterface, DecimalInterface |
11 | 11 | { |
12 | 12 | |
13 | + /** |
|
14 | + * @param ImmutableNumber $mod |
|
15 | + */ |
|
13 | 16 | public function modulo($mod) |
14 | 17 | { |
15 | 18 | $oldBase = $this->convertForModification(); |
@@ -2,9 +2,9 @@ |
||
2 | 2 | |
3 | 3 | namespace Samsara\Fermat\Values; |
4 | 4 | |
5 | -use Samsara\Fermat\Types\Number; |
|
6 | -use Samsara\Fermat\Types\Base\DecimalInterface; |
|
7 | -use Samsara\Fermat\Types\Base\NumberInterface; |
|
5 | +use Samsara\Fermat\Types\Number; |
|
6 | +use Samsara\Fermat\Types\Base\DecimalInterface; |
|
7 | +use Samsara\Fermat\Types\Base\NumberInterface; |
|
8 | 8 | use Samsara\Fermat\Numbers; |
9 | 9 | |
10 | 10 | class MutableNumber extends Number implements NumberInterface, DecimalInterface |
@@ -2,8 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace Samsara\Fermat\Types; |
4 | 4 | |
5 | -use Samsara\Exceptions\SystemError\LogicalError\IncompatibleObjectState; |
|
6 | -use Samsara\Fermat\Numbers; |
|
5 | +use Samsara\Exceptions\SystemError\LogicalError\IncompatibleObjectState; |
|
6 | +use Samsara\Fermat\Numbers; |
|
7 | 7 | use Samsara\Fermat\Values\ImmutableNumber; |
8 | 8 | |
9 | 9 | class Tuple |
@@ -178,7 +178,7 @@ |
||
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
181 | - * @param int|float|DecimalInterface $min |
|
181 | + * @param integer $min |
|
182 | 182 | * @param int|float|DecimalInterface $max |
183 | 183 | * @param int $maxIterations |
184 | 184 | * |
@@ -168,7 +168,7 @@ |
||
168 | 168 | $randFactory = new Factory(); |
169 | 169 | $generator = $randFactory->getMediumStrengthGenerator(); |
170 | 170 | $one = Numbers::makeOne(); |
171 | - $u = $generator->generateInt() / PHP_INT_MAX; |
|
171 | + $u = $generator->generateInt()/PHP_INT_MAX; |
|
172 | 172 | |
173 | 173 | /** @var ImmutableNumber $random */ |
174 | 174 | $random = $one->subtract($u)->ln()->divide($this->lambda->multiply(-1)); |
@@ -163,7 +163,7 @@ |
||
163 | 163 | * WARNING: This function is of very limited use with Poisson distributions, and may represent a SIGNIFICANT |
164 | 164 | * performance hit for certain values of $min, $max, $lambda, and $maxIterations |
165 | 165 | * |
166 | - * @param int|float|NumberInterface $min |
|
166 | + * @param integer $min |
|
167 | 167 | * @param int|float|NumberInterface $max |
168 | 168 | * @param int $maxIterations |
169 | 169 | * |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | $cumulative = Numbers::makeZero(); |
65 | 65 | |
66 | - for ($i = 0;$x->isGreaterThanOrEqualTo($i);$i++) { |
|
66 | + for ($i = 0; $x->isGreaterThanOrEqualTo($i); $i++) { |
|
67 | 67 | $cumulative = $cumulative->add($this->pmf($i)); |
68 | 68 | } |
69 | 69 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | $cumulative = Numbers::makeZero(); |
135 | 135 | |
136 | - for (;$larger->isGreaterThanOrEqualTo($smaller);$smaller->add(1)) { |
|
136 | + for (;$larger->isGreaterThanOrEqualTo($smaller); $smaller->add(1)) { |
|
137 | 137 | $cumulative = $cumulative->add($this->pmf($smaller)); |
138 | 138 | } |
139 | 139 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | |
219 | 219 | while (true) { |
220 | 220 | /** @var ImmutableNumber $u */ |
221 | - $u = $generator->generateInt() / PHP_INT_MAX; |
|
221 | + $u = $generator->generateInt()/PHP_INT_MAX; |
|
222 | 222 | /** @var ImmutableNumber $x */ |
223 | 223 | $x = $alpha->subtract($one->subtract($u)->divide($u)->ln(20)->divide($beta)); |
224 | 224 | /** @var ImmutableNumber $n */ |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | } |
230 | 230 | |
231 | 231 | /** @var ImmutableNumber $v */ |
232 | - $v = $generator->generateInt() / PHP_INT_MAX; |
|
232 | + $v = $generator->generateInt()/PHP_INT_MAX; |
|
233 | 233 | /** @var ImmutableNumber $y */ |
234 | 234 | $y = $alpha->subtract($beta->multiply($x)); |
235 | 235 | /** @var ImmutableNumber $lhs */ |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | do { |
271 | 271 | $k = $k->add(1); |
272 | 272 | /** @var ImmutableNumber $u */ |
273 | - $u = $randFactory->getMediumStrengthGenerator()->generateInt() / PHP_INT_MAX; |
|
273 | + $u = $randFactory->getMediumStrengthGenerator()->generateInt()/PHP_INT_MAX; |
|
274 | 274 | $p = $p->multiply($u); |
275 | 275 | } while ($p->isGreaterThan($L)); |
276 | 276 |
@@ -2,13 +2,12 @@ |
||
2 | 2 | |
3 | 3 | namespace Samsara\Fermat\Provider\Stats\Distribution; |
4 | 4 | |
5 | -use RandomLib\Factory; |
|
6 | -use Samsara\Exceptions\UsageError\IntegrityConstraint; |
|
7 | -use Samsara\Exceptions\UsageError\OptionalExit; |
|
8 | -use Samsara\Fermat\Numbers; |
|
9 | -use Samsara\Fermat\Provider\Stats\Distribution\Base\DistributionInterface; |
|
10 | -use Samsara\Fermat\Types\Base\DecimalInterface; |
|
11 | -use Samsara\Fermat\Types\Base\NumberInterface; |
|
5 | +use RandomLib\Factory; |
|
6 | +use Samsara\Exceptions\UsageError\IntegrityConstraint; |
|
7 | +use Samsara\Exceptions\UsageError\OptionalExit; |
|
8 | +use Samsara\Fermat\Numbers; |
|
9 | +use Samsara\Fermat\Types\Base\DecimalInterface; |
|
10 | +use Samsara\Fermat\Types\Base\NumberInterface; |
|
12 | 11 | use Samsara\Fermat\Values\ImmutableNumber; |
13 | 12 | |
14 | 13 | class Poisson |
@@ -163,7 +163,7 @@ |
||
163 | 163 | * WARNING: This function is of very limited use with Poisson distributions, and may represent a SIGNIFICANT |
164 | 164 | * performance hit for certain values of $min, $max, $lambda, and $maxIterations |
165 | 165 | * |
166 | - * @param int|float|NumberInterface $min |
|
166 | + * @param integer $min |
|
167 | 167 | * @param int|float|NumberInterface $max |
168 | 168 | * @param int $maxIterations |
169 | 169 | * |
@@ -2,12 +2,12 @@ |
||
2 | 2 | |
3 | 3 | namespace Samsara\Fermat\Provider\Stats\Distribution; |
4 | 4 | |
5 | -use RandomLib\Factory; |
|
6 | -use Samsara\Exceptions\UsageError\OptionalExit; |
|
7 | -use Samsara\Fermat\Numbers; |
|
8 | -use Samsara\Fermat\Provider\Stats\Stats; |
|
9 | -use Samsara\Fermat\Types\Base\DecimalInterface; |
|
10 | -use Samsara\Fermat\Types\Base\NumberInterface; |
|
5 | +use RandomLib\Factory; |
|
6 | +use Samsara\Exceptions\UsageError\OptionalExit; |
|
7 | +use Samsara\Fermat\Numbers; |
|
8 | +use Samsara\Fermat\Provider\Stats\Stats; |
|
9 | +use Samsara\Fermat\Types\Base\DecimalInterface; |
|
10 | +use Samsara\Fermat\Types\Base\NumberInterface; |
|
11 | 11 | use Samsara\Fermat\Values\ImmutableNumber; |
12 | 12 | |
13 | 13 | class Normal |
@@ -2,14 +2,14 @@ |
||
2 | 2 | |
3 | 3 | namespace Samsara\Fermat; |
4 | 4 | |
5 | -use Samsara\Exceptions\UsageError\IntegrityConstraint; |
|
6 | -use Samsara\Fermat\Types\Base\DecimalInterface; |
|
7 | -use Samsara\Fermat\Types\Base\FractionInterface; |
|
8 | -use Samsara\Fermat\Values\Currency; |
|
9 | -use Samsara\Fermat\Values\ImmutableFraction; |
|
10 | -use Samsara\Fermat\Values\ImmutableNumber; |
|
11 | -use Samsara\Fermat\Values\MutableFraction; |
|
12 | -use Samsara\Fermat\Values\MutableNumber; |
|
5 | +use Samsara\Exceptions\UsageError\IntegrityConstraint; |
|
6 | +use Samsara\Fermat\Types\Base\DecimalInterface; |
|
7 | +use Samsara\Fermat\Types\Base\FractionInterface; |
|
8 | +use Samsara\Fermat\Values\Currency; |
|
9 | +use Samsara\Fermat\Values\ImmutableFraction; |
|
10 | +use Samsara\Fermat\Values\ImmutableNumber; |
|
11 | +use Samsara\Fermat\Values\MutableFraction; |
|
12 | +use Samsara\Fermat\Values\MutableNumber; |
|
13 | 13 | use Samsara\Fermat\Types\Base\NumberInterface; |
14 | 14 | |
15 | 15 | class Numbers |
@@ -306,6 +306,7 @@ discard block |
||
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
309 | + * @param integer $precision |
|
309 | 310 | * @return ImmutableNumber |
310 | 311 | */ |
311 | 312 | public static function makeOne($precision = null) |
@@ -314,6 +315,7 @@ discard block |
||
314 | 315 | } |
315 | 316 | |
316 | 317 | /** |
318 | + * @param integer $precision |
|
317 | 319 | * @return ImmutableNumber |
318 | 320 | */ |
319 | 321 | public static function makeZero($precision = null) |
@@ -3,10 +3,6 @@ |
||
3 | 3 | namespace Samsara\Fermat\Provider; |
4 | 4 | |
5 | 5 | use Samsara\Fermat\Numbers; |
6 | -use Samsara\Fermat\Types\Cartesian; |
|
7 | -use Samsara\Fermat\Types\Tuple; |
|
8 | -use Samsara\Fermat\Types\Base\NumberInterface; |
|
9 | -use Samsara\Fermat\Values\ImmutableNumber; |
|
10 | 6 | |
11 | 7 | class TrigonometryProvider |
12 | 8 | { |