|
@@ 54-66 (lines=13) @@
|
| 51 |
|
* @return Normal
|
| 52 |
|
* @throws IntegrityConstraint
|
| 53 |
|
*/
|
| 54 |
|
public static function makeFromMean($p, $x, $mean): Normal
|
| 55 |
|
{
|
| 56 |
|
$one = Numbers::makeOne();
|
| 57 |
|
$p = Numbers::makeOrDont(Numbers::IMMUTABLE, $p);
|
| 58 |
|
$x = Numbers::makeOrDont(Numbers::IMMUTABLE, $x);
|
| 59 |
|
$mean = Numbers::makeOrDont(Numbers::IMMUTABLE, $mean);
|
| 60 |
|
|
| 61 |
|
$z = StatsProvider::inverseNormalCDF($one->subtract($p));
|
| 62 |
|
|
| 63 |
|
$sd = $x->subtract($mean)->divide($z);
|
| 64 |
|
|
| 65 |
|
return new Normal($mean, $sd);
|
| 66 |
|
}
|
| 67 |
|
|
| 68 |
|
/**
|
| 69 |
|
* @param int|float|DecimalInterface $p
|
|
@@ 76-88 (lines=13) @@
|
| 73 |
|
* @return Normal
|
| 74 |
|
* @throws IntegrityConstraint
|
| 75 |
|
*/
|
| 76 |
|
public static function makeFromSd($p, $x, $sd): Normal
|
| 77 |
|
{
|
| 78 |
|
$one = Numbers::makeOne();
|
| 79 |
|
$p = Numbers::makeOrDont(Numbers::IMMUTABLE, $p);
|
| 80 |
|
$x = Numbers::makeOrDont(Numbers::IMMUTABLE, $x);
|
| 81 |
|
$sd = Numbers::makeOrDont(Numbers::IMMUTABLE, $sd);
|
| 82 |
|
|
| 83 |
|
$z = StatsProvider::inverseNormalCDF($one->subtract($p));
|
| 84 |
|
|
| 85 |
|
$mean = $x->subtract($z->multiply($sd));
|
| 86 |
|
|
| 87 |
|
return new Normal($mean, $sd);
|
| 88 |
|
}
|
| 89 |
|
|
| 90 |
|
/**
|
| 91 |
|
* @param int|float|DecimalInterface $x
|