@@ -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));  | 
                                                        
@@ -88,6 +88,9 @@  | 
                                                    ||
| 88 | 88 | |
| 89 | 89 | }  | 
                                                        
| 90 | 90 | |
| 91 | + /**  | 
                                                        |
| 92 | + * @param NumberInterface $p  | 
                                                        |
| 93 | + */  | 
                                                        |
| 91 | 94 | public static function inverseNormalCDF($p, $precision = 10)  | 
                                                        
| 92 | 95 |      { | 
                                                        
| 93 | 96 | $pi = Numbers::makePi();  | 
                                                        
@@ -2,9 +2,9 @@  | 
                                                    ||
| 2 | 2 | |
| 3 | 3 | namespace Samsara\Fermat\Provider\Stats\Distribution;  | 
                                                        
| 4 | 4 | |
| 5 | -use RandomLib\Factory;  | 
                                                        |
| 6 | -use Samsara\Fermat\Numbers;  | 
                                                        |
| 7 | -use Samsara\Fermat\Provider\Stats\Distribution\Base\DistributionInterface;  | 
                                                        |
| 5 | +use RandomLib\Factory;  | 
                                                        |
| 6 | +use Samsara\Fermat\Numbers;  | 
                                                        |
| 7 | +use Samsara\Fermat\Provider\Stats\Distribution\Base\DistributionInterface;  | 
                                                        |
| 8 | 8 | use Samsara\Fermat\Values\Base\NumberInterface;  | 
                                                        
| 9 | 9 | |
| 10 | 10 | class Poisson implements DistributionInterface  | 
                                                        
@@ -33,7 +33,7 @@ discard block  | 
                                                    ||
| 33 | 33 | $cumulative = Numbers::makeZero();  | 
                                                        
| 34 | 34 | $x = Numbers::makeOrDont(Numbers::IMMUTABLE, $x);  | 
                                                        
| 35 | 35 | |
| 36 | -        for ($i = 0;$x->isGreaterThanOrEqualTo($i);$i++) {
 | 
                                                        |
| 36 | +        for ($i = 0; $x->isGreaterThanOrEqualTo($i); $i++) {
 | 
                                                        |
| 37 | 37 | $cumulative = $cumulative->add($this->pmf($i));  | 
                                                        
| 38 | 38 | }  | 
                                                        
| 39 | 39 | |
@@ -62,7 +62,7 @@ discard block  | 
                                                    ||
| 62 | 62 | |
| 63 | 63 | $cumulative = Numbers::makeZero();  | 
                                                        
| 64 | 64 | |
| 65 | -        for (;$larger->isGreaterThanOrEqualTo($smaller);$smaller->add(1)) {
 | 
                                                        |
| 65 | +        for (;$larger->isGreaterThanOrEqualTo($smaller); $smaller->add(1)) {
 | 
                                                        |
| 66 | 66 | $cumulative = $cumulative->add($this->pmf($smaller));  | 
                                                        
| 67 | 67 | }  | 
                                                        
| 68 | 68 | |
@@ -96,7 +96,7 @@ discard block  | 
                                                    ||
| 96 | 96 | |
| 97 | 97 |          while ($p->isLessThan($L)) {
 | 
                                                        
| 98 | 98 | $k = $k->add(1);  | 
                                                        
| 99 | - $u = $randFactory->getMediumStrengthGenerator()->generateInt() / PHP_INT_MAX;  | 
                                                        |
| 99 | + $u = $randFactory->getMediumStrengthGenerator()->generateInt()/PHP_INT_MAX;  | 
                                                        |
| 100 | 100 | $p = $p->multiply($u);  | 
                                                        
| 101 | 101 | }  | 
                                                        
| 102 | 102 | |
@@ -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  | 
                                                        
@@ -69,7 +69,7 @@  | 
                                                    ||
| 69 | 69 | |
| 70 | 70 | $t = Numbers::makeZero();  | 
                                                        
| 71 | 71 | |
| 72 | -        for ($k = 0;$m->isGreaterThanOrEqualTo($k);$k++) { | 
                                                        |
| 72 | +        for ($k = 0; $m->isGreaterThanOrEqualTo($k); $k++) { | 
                                                        |
| 73 | 73 | $kNum = Numbers::make(Numbers::IMMUTABLE, $k);  | 
                                                        
| 74 | 74 | $combination = $m->factorial()->divide($kNum->factorial()->multiply($m->subtract($k)->factorial()));  | 
                                                        
| 75 | 75 | $t = $t->add($combination->multiply(self::nthBernoulliNumber($k, $n))->divide($m->subtract($k)->add(1)));  | 
                                                        
@@ -2,12 +2,12 @@  | 
                                                    ||
| 2 | 2 | |
| 3 | 3 | namespace Samsara\Fermat;  | 
                                                        
| 4 | 4 | |
| 5 | -use Samsara\Exceptions\UsageError\IntegrityConstraint;  | 
                                                        |
| 6 | -use Samsara\Fermat\Values\Currency;  | 
                                                        |
| 7 | -use Samsara\Fermat\Values\ImmutableFraction;  | 
                                                        |
| 8 | -use Samsara\Fermat\Values\ImmutableNumber;  | 
                                                        |
| 9 | -use Samsara\Fermat\Values\MutableFraction;  | 
                                                        |
| 10 | -use Samsara\Fermat\Values\MutableNumber;  | 
                                                        |
| 5 | +use Samsara\Exceptions\UsageError\IntegrityConstraint;  | 
                                                        |
| 6 | +use Samsara\Fermat\Values\Currency;  | 
                                                        |
| 7 | +use Samsara\Fermat\Values\ImmutableFraction;  | 
                                                        |
| 8 | +use Samsara\Fermat\Values\ImmutableNumber;  | 
                                                        |
| 9 | +use Samsara\Fermat\Values\MutableFraction;  | 
                                                        |
| 10 | +use Samsara\Fermat\Values\MutableNumber;  | 
                                                        |
| 11 | 11 | use Samsara\Fermat\Types\Base\NumberInterface;  | 
                                                        
| 12 | 12 | |
| 13 | 13 | class Numbers  | 
                                                        
@@ -26,7 +26,7 @@ discard block  | 
                                                    ||
| 26 | 26 | public function __construct($value, $precision = null, $base = 10)  | 
                                                        
| 27 | 27 |      {
 | 
                                                        
| 28 | 28 | $this->base = $base;  | 
                                                        
| 29 | - $this->value = (string)$value;  | 
                                                        |
| 29 | + $this->value = (string) $value;  | 
                                                        |
| 30 | 30 | |
| 31 | 31 |          if (!is_null($precision)) {
 | 
                                                        
| 32 | 32 | $this->precision = $precision;  | 
                                                        
@@ -136,7 +136,7 @@ discard block  | 
                                                    ||
| 136 | 136 | $curVal = $this->getValue();  | 
                                                        
| 137 | 137 | $calcVal = Numbers::make(Numbers::IMMUTABLE, 1);  | 
                                                        
| 138 | 138 | |
| 139 | -        for ($i = 1;$i <= $curVal;$i++) {
 | 
                                                        |
| 139 | +        for ($i = 1; $i <= $curVal; $i++) {
 | 
                                                        |
| 140 | 140 | $calcVal = $calcVal->multiply($i);  | 
                                                        
| 141 | 141 | }  | 
                                                        
| 142 | 142 | |
@@ -152,19 +152,19 @@ discard block  | 
                                                    ||
| 152 | 152 | |
| 153 | 153 |          if ($val->modulo(2)->isEqual(1)) {
 | 
                                                        
| 154 | 154 | $m = Numbers::make(Numbers::IMMUTABLE, $val->add(1)->divide(2));  | 
                                                        
| 155 | -            $term = function ($n) {
 | 
                                                        |
| 155 | +            $term = function($n) {
 | 
                                                        |
| 156 | 156 | return Numbers::make(Numbers::IMMUTABLE, 2)->multiply($n);  | 
                                                        
| 157 | 157 | };  | 
                                                        
| 158 | 158 |          } else {
 | 
                                                        
| 159 | 159 | $m = Numbers::make(Numbers::IMMUTABLE, $val->divide(2));  | 
                                                        
| 160 | -            $term = function ($n) {
 | 
                                                        |
| 160 | +            $term = function($n) {
 | 
                                                        |
| 161 | 161 | return Numbers::make(Numbers::IMMUTABLE, 2)->multiply($n)->subtract(1);  | 
                                                        
| 162 | 162 | };  | 
                                                        
| 163 | 163 | }  | 
                                                        
| 164 | 164 | |
| 165 | 165 | $newVal = Numbers::makeOne();  | 
                                                        
| 166 | 166 | |
| 167 | -        for ($i = 1;$m->isGreaterThanOrEqualTo($i);$i++) {
 | 
                                                        |
| 167 | +        for ($i = 1; $m->isGreaterThanOrEqualTo($i); $i++) {
 | 
                                                        |
| 168 | 168 | $newVal = $newVal->multiply($term($i));  | 
                                                        
| 169 | 169 | }  | 
                                                        
| 170 | 170 | |
@@ -197,7 +197,7 @@ discard block  | 
                                                    ||
| 197 | 197 | $oldBase = $this->convertForModification();  | 
                                                        
| 198 | 198 | |
| 199 | 199 |          if ($this->isGreaterThanOrEqualTo(PHP_INT_MIN) && $this->isLessThanOrEqualTo(PHP_INT_MAX)) {
 | 
                                                        
| 200 | - return $this->setValue(log((float)$this->getValue()))->convertFromModification($oldBase);  | 
                                                        |
| 200 | + return $this->setValue(log((float) $this->getValue()))->convertFromModification($oldBase);  | 
                                                        |
| 201 | 201 | }  | 
                                                        
| 202 | 202 | |
| 203 | 203 | $x = Numbers::make(Numbers::IMMUTABLE, $this->getValue(), $this->getPrecision());  | 
                                                        
@@ -269,15 +269,15 @@ discard block  | 
                                                    ||
| 269 | 269 | return $this->setValue(  | 
                                                        
| 270 | 270 | SeriesProvider::maclaurinSeries(  | 
                                                        
| 271 | 271 | Numbers::make(Numbers::IMMUTABLE, $value),  | 
                                                        
| 272 | -                    function ($n) {
 | 
                                                        |
| 272 | +                    function($n) {
 | 
                                                        |
| 273 | 273 | $negOne = Numbers::make(Numbers::IMMUTABLE, -1);  | 
                                                        
| 274 | 274 | |
| 275 | 275 | return $negOne->pow($n);  | 
                                                        
| 276 | 276 | },  | 
                                                        
| 277 | -                    function ($n) {
 | 
                                                        |
| 277 | +                    function($n) {
 | 
                                                        |
| 278 | 278 | return SequenceProvider::nthOddNumber($n);  | 
                                                        
| 279 | 279 | },  | 
                                                        
| 280 | -                    function ($n) {
 | 
                                                        |
| 280 | +                    function($n) {
 | 
                                                        |
| 281 | 281 | return SequenceProvider::nthOddNumber($n)->factorial();  | 
                                                        
| 282 | 282 | },  | 
                                                        
| 283 | 283 | 0,  | 
                                                        
@@ -315,13 +315,13 @@ discard block  | 
                                                    ||
| 315 | 315 | return $this->setValue(  | 
                                                        
| 316 | 316 | SeriesProvider::maclaurinSeries(  | 
                                                        
| 317 | 317 | Numbers::make(Numbers::IMMUTABLE, $value),  | 
                                                        
| 318 | -                    function ($n) {
 | 
                                                        |
| 318 | +                    function($n) {
 | 
                                                        |
| 319 | 319 | return SequenceProvider::nthPowerNegativeOne($n);  | 
                                                        
| 320 | 320 | },  | 
                                                        
| 321 | -                    function ($n) {
 | 
                                                        |
| 321 | +                    function($n) {
 | 
                                                        |
| 322 | 322 | return SequenceProvider::nthEvenNumber($n);  | 
                                                        
| 323 | 323 | },  | 
                                                        
| 324 | -                    function ($n) {
 | 
                                                        |
| 324 | +                    function($n) {
 | 
                                                        |
| 325 | 325 | return SequenceProvider::nthEvenNumber($n)->factorial();  | 
                                                        
| 326 | 326 | },  | 
                                                        
| 327 | 327 | 0,  | 
                                                        
@@ -355,18 +355,18 @@ discard block  | 
                                                    ||
| 355 | 355 | return $this->setValue(  | 
                                                        
| 356 | 356 | SeriesProvider::maclaurinSeries(  | 
                                                        
| 357 | 357 | Numbers::make(Numbers::IMMUTABLE, $value),  | 
                                                        
| 358 | -                    function ($n) {
 | 
                                                        |
| 358 | +                    function($n) {
 | 
                                                        |
| 359 | 359 | $four = Numbers::make(Numbers::IMMUTABLE, 4);  | 
                                                        
| 360 | 360 | $n = Numbers::makeOrDont(Numbers::IMMUTABLE, $n);  | 
                                                        
| 361 | 361 | |
| 362 | 362 | return SequenceProvider::nthBernoulliNumber($n->multiply(2)->getValue(), -4)->pow($n)->multiply(Numbers::makeOne()->subtract($four->pow($n)));  | 
                                                        
| 363 | 363 | },  | 
                                                        
| 364 | -                    function ($n) {
 | 
                                                        |
| 364 | +                    function($n) {
 | 
                                                        |
| 365 | 365 | $n = Numbers::makeOrDont(Numbers::IMMUTABLE, $n);  | 
                                                        
| 366 | 366 | |
| 367 | 367 | return $n->multiply(2)->subtract(1);  | 
                                                        
| 368 | 368 | },  | 
                                                        
| 369 | -                    function ($n) {
 | 
                                                        |
| 369 | +                    function($n) {
 | 
                                                        |
| 370 | 370 | return SequenceProvider::nthEvenNumber($n)->factorial();  | 
                                                        
| 371 | 371 | },  | 
                                                        
| 372 | 372 | 1,  | 
                                                        
@@ -52,6 +52,9 @@ discard block  | 
                                                    ||
| 52 | 52 | return $this->precision;  | 
                                                        
| 53 | 53 | }  | 
                                                        
| 54 | 54 | |
| 55 | + /**  | 
                                                        |
| 56 | + * @param NumberInterface $num  | 
                                                        |
| 57 | + */  | 
                                                        |
| 55 | 58 | public function add($num)  | 
                                                        
| 56 | 59 |      {
 | 
                                                        
| 57 | 60 | $num = Numbers::makeOrDont($this, $num, $this->getPrecision());  | 
                                                        
@@ -101,7 +104,7 @@ discard block  | 
                                                    ||
| 101 | 104 | * Note about precision: it uses the smaller of the two precisions (significant figures).  | 
                                                        
| 102 | 105 | *  | 
                                                        
| 103 | 106 | * @param $num  | 
                                                        
| 104 | - * @return mixed  | 
                                                        |
| 107 | + * @return NumberInterface  | 
                                                        |
| 105 | 108 | */  | 
                                                        
| 106 | 109 | public function divide($num)  | 
                                                        
| 107 | 110 |      {
 | 
                                                        
@@ -398,6 +401,9 @@ discard block  | 
                                                    ||
| 398 | 401 | |
| 399 | 402 | }  | 
                                                        
| 400 | 403 | |
| 404 | + /**  | 
                                                        |
| 405 | + * @param ImmutableNumber $num  | 
                                                        |
| 406 | + */  | 
                                                        |
| 401 | 407 | public function getGreatestCommonDivisor($num)  | 
                                                        
| 402 | 408 |      {
 | 
                                                        
| 403 | 409 | /** @var ImmutableNumber $num */  | 
                                                        
@@ -2,16 +2,16 @@  | 
                                                    ||
| 2 | 2 | |
| 3 | 3 | namespace Samsara\Fermat\Types;  | 
                                                        
| 4 | 4 | |
| 5 | -use Ds\Hashable;  | 
                                                        |
| 6 | -use Samsara\Exceptions\SystemError\LogicalError\IncompatibleObjectState;  | 
                                                        |
| 7 | -use Samsara\Exceptions\UsageError\IntegrityConstraint;  | 
                                                        |
| 8 | -use Samsara\Fermat\Numbers;  | 
                                                        |
| 9 | -use Samsara\Fermat\Provider\ArithmeticProvider;  | 
                                                        |
| 10 | -use Riimu\Kit\BaseConversion\BaseConverter;  | 
                                                        |
| 11 | -use Samsara\Fermat\Provider\SequenceProvider;  | 
                                                        |
| 12 | -use Samsara\Fermat\Provider\SeriesProvider;  | 
                                                        |
| 13 | -use Samsara\Fermat\Types\Base\DecimalInterface;  | 
                                                        |
| 14 | -use Samsara\Fermat\Types\Base\NumberInterface;  | 
                                                        |
| 5 | +use Ds\Hashable;  | 
                                                        |
| 6 | +use Samsara\Exceptions\SystemError\LogicalError\IncompatibleObjectState;  | 
                                                        |
| 7 | +use Samsara\Exceptions\UsageError\IntegrityConstraint;  | 
                                                        |
| 8 | +use Samsara\Fermat\Numbers;  | 
                                                        |
| 9 | +use Samsara\Fermat\Provider\ArithmeticProvider;  | 
                                                        |
| 10 | +use Riimu\Kit\BaseConversion\BaseConverter;  | 
                                                        |
| 11 | +use Samsara\Fermat\Provider\SequenceProvider;  | 
                                                        |
| 12 | +use Samsara\Fermat\Provider\SeriesProvider;  | 
                                                        |
| 13 | +use Samsara\Fermat\Types\Base\DecimalInterface;  | 
                                                        |
| 14 | +use Samsara\Fermat\Types\Base\NumberInterface;  | 
                                                        |
| 15 | 15 | use Samsara\Fermat\Values\ImmutableNumber;  | 
                                                        
| 16 | 16 | |
| 17 | 17 | abstract class Number implements Hashable  | 
                                                        
@@ -21,6 +21,10 @@ discard block  | 
                                                    ||
| 21 | 21 | |
| 22 | 22 | protected $symbol;  | 
                                                        
| 23 | 23 | |
| 24 | + /**  | 
                                                        |
| 25 | + * @param integer $symbol  | 
                                                        |
| 26 | + * @param integer $precision  | 
                                                        |
| 27 | + */  | 
                                                        |
| 24 | 28 | public function __construct($value, $symbol = Currency::DOLLAR, $precision = null, $base = 10)  | 
                                                        
| 25 | 29 |      { | 
                                                        
| 26 | 30 | $this->symbol = $symbol;  | 
                                                        
@@ -63,7 +67,7 @@ discard block  | 
                                                    ||
| 63 | 67 | }  | 
                                                        
| 64 | 68 | |
| 65 | 69 | /**  | 
                                                        
| 66 | - * @param $value  | 
                                                        |
| 70 | + * @param NumberInterface $value  | 
                                                        |
| 67 | 71 | *  | 
                                                        
| 68 | 72 | * @return Currency  | 
                                                        
| 69 | 73 | */  |