MathPHP\Probability\Distribution\Continuous\Normal::PDF PHP Method

PDF() public static method

1 f(x|μ,σ) = ----- ℯ^−⟮x − μ⟯²∕2σ² σ√⟮2π⟯
public static PDF ( number $x, number , number ) : float
$x number random variable
number mean
number standard deviation
return float f(x|μ,σ)
    public static function PDF($x, $μ, $σ) : float
    {
        Support::checkLimits(self::LIMITS, ['x' => $x, 'μ' => $μ, 'σ' => $σ]);
        $π = \M_PI;
        $σ√⟮2π⟯ = $σ * sqrt(2 * $π);
        $⟮x − μ⟯²∕2σ² = pow($x - $μ, 2) / (2 * $σ ** 2);
        $ℯ^−⟮x − μ⟯²∕2σ² = exp(-$⟮x − μ⟯²∕2σ²);
        return 1 / $σ√⟮2π⟯ * $ℯ^−⟮x − μ⟯²∕2σ²;
    }

Usage Example

Example #1
0
 /**
  * Probability density function
  *
  * @param number $z random variable
  *
  * @return float f(z|μ,σ)
  */
 public static function PDF($z)
 {
     Support::checkLimits(self::LIMITS, ['z' => $z]);
     return Normal::PDF($z, self::μ, self::σ);
 }