@@ -69,6 +69,9 @@ discard block |
||
69 | 69 | ); |
70 | 70 | } |
71 | 71 | |
72 | + /** |
|
73 | + * @param NumberInterface $standardDev |
|
74 | + */ |
|
72 | 75 | public function SDToValue($standardDev) |
73 | 76 | { |
74 | 77 | $standardDev = Numbers::makeOrDont($this->numberType, $standardDev); |
@@ -85,6 +88,9 @@ discard block |
||
85 | 88 | return $this->PDFByValue($value); |
86 | 89 | } |
87 | 90 | |
91 | + /** |
|
92 | + * @param NumberInterface $value |
|
93 | + */ |
|
88 | 94 | public function PDFByValue($value) |
89 | 95 | { |
90 | 96 | $value = Numbers::makeOrDont($this->numberType, $value); |
@@ -2,10 +2,10 @@ |
||
2 | 2 | |
3 | 3 | namespace Samsara\Fermat\Context; |
4 | 4 | |
5 | -use Samsara\Fermat\Context\Base\BaseContext; |
|
6 | -use Samsara\Fermat\Numbers; |
|
7 | -use Samsara\Fermat\Provider\BCProvider; |
|
8 | -use Samsara\Fermat\Provider\GaussianProvider; |
|
5 | +use Samsara\Fermat\Context\Base\BaseContext; |
|
6 | +use Samsara\Fermat\Numbers; |
|
7 | +use Samsara\Fermat\Provider\BCProvider; |
|
8 | +use Samsara\Fermat\Provider\GaussianProvider; |
|
9 | 9 | use Samsara\Fermat\Values\Base\NumberInterface; |
10 | 10 | |
11 | 11 | /** |
@@ -2,12 +2,12 @@ |
||
2 | 2 | |
3 | 3 | namespace Samsara\Fermat\Context; |
4 | 4 | |
5 | -use RandomLib\Factory; |
|
6 | -use Samsara\Fermat\Context\Base\BaseContext; |
|
7 | -use Samsara\Fermat\Context\Base\ContextInterface; |
|
8 | -use Samsara\Fermat\Numbers; |
|
9 | -use Samsara\Fermat\Provider\BCProvider; |
|
10 | -use Samsara\Fermat\Values\ImmutableNumber; |
|
5 | +use RandomLib\Factory; |
|
6 | +use Samsara\Fermat\Context\Base\BaseContext; |
|
7 | +use Samsara\Fermat\Context\Base\ContextInterface; |
|
8 | +use Samsara\Fermat\Numbers; |
|
9 | +use Samsara\Fermat\Provider\BCProvider; |
|
10 | +use Samsara\Fermat\Values\ImmutableNumber; |
|
11 | 11 | use Samsara\Fermat\Values\Base\NumberInterface; |
12 | 12 | |
13 | 13 | class UniformContext extends BaseContext implements ContextInterface |
@@ -2,9 +2,9 @@ |
||
2 | 2 | |
3 | 3 | namespace Samsara\Fermat; |
4 | 4 | |
5 | -use Samsara\Fermat\Values\ImmutableFraction; |
|
6 | -use Samsara\Fermat\Values\ImmutableNumber; |
|
7 | -use Samsara\Fermat\Values\MutableNumber; |
|
5 | +use Samsara\Fermat\Values\ImmutableFraction; |
|
6 | +use Samsara\Fermat\Values\ImmutableNumber; |
|
7 | +use Samsara\Fermat\Values\MutableNumber; |
|
8 | 8 | use Samsara\Fermat\Values\Base\NumberInterface; |
9 | 9 | |
10 | 10 | class Numbers |
@@ -19,6 +19,10 @@ |
||
19 | 19 | */ |
20 | 20 | private $sd; |
21 | 21 | |
22 | + /** |
|
23 | + * @param NumberInterface $mean |
|
24 | + * @param NumberInterface $sd |
|
25 | + */ |
|
22 | 26 | public function __construct($mean, $sd) |
23 | 27 | { |
24 | 28 | $mean = Numbers::makeOrDont(Numbers::IMMUTABLE, $mean); |
@@ -2,8 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace Samsara\Fermat\Provider\Stats\Distribution; |
4 | 4 | |
5 | -use Samsara\Fermat\Numbers; |
|
6 | -use Samsara\Fermat\Provider\Stats\Stats; |
|
5 | +use Samsara\Fermat\Numbers; |
|
6 | +use Samsara\Fermat\Provider\Stats\Stats; |
|
7 | 7 | use Samsara\Fermat\Values\Base\NumberInterface; |
8 | 8 | |
9 | 9 | class Normal |
@@ -56,6 +56,9 @@ discard block |
||
56 | 56 | return $one->subtract($p); |
57 | 57 | } |
58 | 58 | |
59 | + /** |
|
60 | + * @param NumberInterface $x |
|
61 | + */ |
|
59 | 62 | public static function gaussErrorFunction($x) |
60 | 63 | { |
61 | 64 | |
@@ -68,14 +71,26 @@ discard block |
||
68 | 71 | $answer = $answer->multiply( |
69 | 72 | SeriesProvider::maclaurinSeries( |
70 | 73 | $x, |
74 | + |
|
75 | + /** |
|
76 | + * @param NumberInterface $n |
|
77 | + */ |
|
71 | 78 | function ($n) { |
72 | 79 | $negOne = Numbers::make(Numbers::IMMUTABLE, -1); |
73 | 80 | |
74 | 81 | return $negOne->pow($n); |
75 | 82 | }, |
83 | + |
|
84 | + /** |
|
85 | + * @param NumberInterface $n |
|
86 | + */ |
|
76 | 87 | function ($n) { |
77 | 88 | return SequenceProvider::nthOddNumber($n); |
78 | 89 | }, |
90 | + |
|
91 | + /** |
|
92 | + * @param NumberInterface $n |
|
93 | + */ |
|
79 | 94 | function ($n) { |
80 | 95 | $n = Numbers::makeOrDont(Numbers::IMMUTABLE, $n); |
81 | 96 | |
@@ -88,6 +103,9 @@ discard block |
||
88 | 103 | |
89 | 104 | } |
90 | 105 | |
106 | + /** |
|
107 | + * @param NumberInterface $p |
|
108 | + */ |
|
91 | 109 | public static function inverseNormalCDF($p, $precision = 10) |
92 | 110 | { |
93 | 111 | $pi = Numbers::makePi(); |
@@ -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)); |
@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use Samsara\Fermat\Numbers; |
6 | 6 | use Samsara\Fermat\Types\Cartesian; |
7 | -use Samsara\Fermat\Types\Tuple; |
|
8 | 7 | use Samsara\Fermat\Values\Base\NumberInterface; |
9 | 8 | use Samsara\Fermat\Values\ImmutableNumber; |
10 | 9 |
@@ -23,6 +23,9 @@ |
||
23 | 23 | */ |
24 | 24 | private $denominator; |
25 | 25 | |
26 | + /** |
|
27 | + * @param string $numerator |
|
28 | + */ |
|
26 | 29 | public function __construct($numerator, $denominator, $precision = null, $base = 10) |
27 | 30 | { |
28 | 31 |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | namespace Samsara\Fermat\Types; |
4 | 4 | |
5 | -use Samsara\Fermat\Numbers; |
|
5 | +use Samsara\Fermat\Numbers; |
|
6 | 6 | use Samsara\Fermat\Values\ImmutableNumber; |
7 | 7 | |
8 | 8 | class Tuple |
@@ -2,9 +2,9 @@ |
||
2 | 2 | |
3 | 3 | namespace Samsara\Fermat\Values; |
4 | 4 | |
5 | -use Samsara\Fermat\Types\Cartesian; |
|
6 | -use Samsara\Fermat\Types\Tuple; |
|
7 | -use Samsara\Fermat\Types\Vector; |
|
5 | +use Samsara\Fermat\Types\Cartesian; |
|
6 | +use Samsara\Fermat\Types\Tuple; |
|
7 | +use Samsara\Fermat\Types\Vector; |
|
8 | 8 | use Samsara\Fermat\Values\Base\VectorInterface; |
9 | 9 | |
10 | 10 | class ImmutableVector extends Vector implements VectorInterface |