@@ -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)); |
@@ -2,12 +2,12 @@ |
||
2 | 2 | |
3 | 3 | namespace Samsara\Fermat\Provider\Distribution; |
4 | 4 | |
5 | -use RandomLib\Factory; |
|
6 | -use Samsara\Exceptions\UsageError\OptionalExit; |
|
7 | -use Samsara\Fermat\Numbers; |
|
8 | -use Samsara\Fermat\Provider\StatsProvider; |
|
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\StatsProvider; |
|
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 |
@@ -158,7 +158,7 @@ |
||
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
161 | - * @param int|float|NumberInterface $min |
|
161 | + * @param integer $min |
|
162 | 162 | * @param int|float|NumberInterface $max |
163 | 163 | * @param int $maxIterations |
164 | 164 | * |
@@ -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,12 +2,12 @@ |
||
2 | 2 | |
3 | 3 | namespace Samsara\Fermat\Provider\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\Types\Base\DecimalInterface; |
|
10 | -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; |
|
11 | 11 | use Samsara\Fermat\Values\ImmutableNumber; |
12 | 12 | |
13 | 13 | class Poisson |
@@ -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)); |
@@ -11,57 +11,57 @@ |
||
11 | 11 | { |
12 | 12 | |
13 | 13 | const EULER_ZIGZAG = [ |
14 | - '1', // 0 |
|
15 | - '1', // 1 |
|
16 | - '1', // 2 |
|
17 | - '2', // 3 |
|
18 | - '5', // 4 |
|
19 | - '16', // 5 |
|
20 | - '61', // 6 |
|
21 | - '272', // 7 |
|
22 | - '1385', // 8 |
|
23 | - '7936', // 9 |
|
24 | - '50521', // 10 |
|
25 | - '353792', // 11 |
|
26 | - '2702765', // 12 |
|
27 | - '22368256', // 13 |
|
28 | - '199360981', // 14 |
|
29 | - '1903757312', // 15 |
|
30 | - '19391512145', // 16 |
|
31 | - '209865342976', // 17 |
|
32 | - '2404879675441', // 18 |
|
33 | - '29088885112832', // 19 |
|
34 | - '370371188237525', // 20 |
|
35 | - '4951498053124096', // 21 |
|
36 | - '69348874393137901', // 22 |
|
37 | - '1015423886506852352', // 23 |
|
38 | - '15514534163557086905', // 24 |
|
39 | - '246921480190207983616', // 25 |
|
40 | - '4087072509293123892361', // 26 |
|
41 | - '70251601603943959887872', // 27 |
|
42 | - '1252259641403629865468285', // 28 |
|
43 | - '23119184187809597841473536', // 29 |
|
44 | - '441543893249023104553682821', // 30 |
|
45 | - '8713962757125169296170811392', // 31 |
|
46 | - '177519391579539289436664789665', // 32 |
|
47 | - '3729407703720529571097509625856', // 33 |
|
48 | - '80723299235887898062168247453281', // 34 |
|
49 | - '1798651693450888780071750349094912', // 35 |
|
50 | - '41222060339517702122347079671259045', // 36 |
|
51 | - '970982810785059112379399707952152576', // 37 |
|
52 | - '23489580527043108252017828576198947741', // 38 |
|
53 | - '583203324917310043943191641625494290432', // 39 |
|
54 | - '14851150718114980017877156781405826684425', // 40 |
|
55 | - '387635983772083031828014624002175135645696', // 41 |
|
56 | - '10364622733519612119397957304745185976310201', // 42 |
|
57 | - '283727921907431909304183316295787837183229952', // 43 |
|
58 | - '7947579422597592703608040510088070619519273805', // 44 |
|
59 | - '227681379129930886488600284336316164603920777216', // 45 |
|
60 | - '6667537516685544977435028474773748197524107684661', // 46 |
|
61 | - '199500252157859031027160499643195658166340757225472', // 47 |
|
62 | - '6096278645568542158691685742876843153976539044435185', // 48 |
|
63 | - '190169564657928428175235445073924928592047775873499136', // 49 |
|
64 | - '6053285248188621896314383785111649088103498225146815121', // 50 |
|
14 | + '1', // 0 |
|
15 | + '1', // 1 |
|
16 | + '1', // 2 |
|
17 | + '2', // 3 |
|
18 | + '5', // 4 |
|
19 | + '16', // 5 |
|
20 | + '61', // 6 |
|
21 | + '272', // 7 |
|
22 | + '1385', // 8 |
|
23 | + '7936', // 9 |
|
24 | + '50521', // 10 |
|
25 | + '353792', // 11 |
|
26 | + '2702765', // 12 |
|
27 | + '22368256', // 13 |
|
28 | + '199360981', // 14 |
|
29 | + '1903757312', // 15 |
|
30 | + '19391512145', // 16 |
|
31 | + '209865342976', // 17 |
|
32 | + '2404879675441', // 18 |
|
33 | + '29088885112832', // 19 |
|
34 | + '370371188237525', // 20 |
|
35 | + '4951498053124096', // 21 |
|
36 | + '69348874393137901', // 22 |
|
37 | + '1015423886506852352', // 23 |
|
38 | + '15514534163557086905', // 24 |
|
39 | + '246921480190207983616', // 25 |
|
40 | + '4087072509293123892361', // 26 |
|
41 | + '70251601603943959887872', // 27 |
|
42 | + '1252259641403629865468285', // 28 |
|
43 | + '23119184187809597841473536', // 29 |
|
44 | + '441543893249023104553682821', // 30 |
|
45 | + '8713962757125169296170811392', // 31 |
|
46 | + '177519391579539289436664789665', // 32 |
|
47 | + '3729407703720529571097509625856', // 33 |
|
48 | + '80723299235887898062168247453281', // 34 |
|
49 | + '1798651693450888780071750349094912', // 35 |
|
50 | + '41222060339517702122347079671259045', // 36 |
|
51 | + '970982810785059112379399707952152576', // 37 |
|
52 | + '23489580527043108252017828576198947741', // 38 |
|
53 | + '583203324917310043943191641625494290432', // 39 |
|
54 | + '14851150718114980017877156781405826684425', // 40 |
|
55 | + '387635983772083031828014624002175135645696', // 41 |
|
56 | + '10364622733519612119397957304745185976310201', // 42 |
|
57 | + '283727921907431909304183316295787837183229952', // 43 |
|
58 | + '7947579422597592703608040510088070619519273805', // 44 |
|
59 | + '227681379129930886488600284336316164603920777216', // 45 |
|
60 | + '6667537516685544977435028474773748197524107684661', // 46 |
|
61 | + '199500252157859031027160499643195658166340757225472', // 47 |
|
62 | + '6096278645568542158691685742876843153976539044435185', // 48 |
|
63 | + '190169564657928428175235445073924928592047775873499136', // 49 |
|
64 | + '6053285248188621896314383785111649088103498225146815121', // 50 |
|
65 | 65 | ]; |
66 | 66 | |
67 | 67 | /** |
@@ -24,6 +24,10 @@ |
||
24 | 24 | */ |
25 | 25 | protected $denominator; |
26 | 26 | |
27 | + /** |
|
28 | + * @param ImmutableNumber $numerator |
|
29 | + * @param ImmutableNumber $denominator |
|
30 | + */ |
|
27 | 31 | public function __construct($numerator, $denominator, $base = 10) |
28 | 32 | { |
29 | 33 |