fix cdf function + add icdf

This commit is contained in:
Dennis Eichhorn 2023-08-14 16:39:53 +00:00
parent ab023cad8b
commit 61c9bacb80

View File

@ -101,7 +101,13 @@ final class NormalDistribution
*/ */
public static function getCdf(float $x, float $mu, float $sig) : float public static function getCdf(float $x, float $mu, float $sig) : float
{ {
return 1 / 2 * (1 + Functions::getErf(($x - $mu) / ($sig * \sqrt(2)))); return 0.5 * Functions::getErf(-($x - $mu) / ($sig * \sqrt(2)));
}
// AKA Quantile function and sometimes PPF
public static function getICdf(float $x, float $mu, float $sig) : float
{
return $mu - $sig * \sqrt(2) * Functions::getInvErfc(2 * $x);
} }
/** /**