Created
December 6, 2020 16:46
-
-
Save fatihgune/356bd8e135338660860cb71560bac925 to your computer and use it in GitHub Desktop.
Return Probability From the Table (PHP)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
public function returnProbabilityFromTheTable($zValue) | |
{ | |
return $this->CDF($zValue); | |
} | |
public function sgn($x) | |
{ | |
if ($x < 0) { | |
return -1; | |
} | |
return 1; | |
} | |
public function erf($x) | |
{ | |
$e = exp(-$x * $x); | |
$e2 = exp(-$x * $x * 2); | |
$q = sqrt(pi()) / 2 + 31 * $e / 200 - 341 * $e2 / 8000; | |
return 2 * $this->sgn($x) * sqrt(1 - $e) * $q / sqrt(pi()); | |
} | |
public function CDF($x) | |
{ | |
return (1 + $this->erf($x / sqrt(2))) / 2; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment