Cumulative distribution function for generalised pareto distribution.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x |
sample position |
||
real(kind=wp), | intent(in) | :: | xi |
distribution shape parameter |
||
real(kind=wp), | intent(in) | :: | mu |
distribution location |
||
real(kind=wp), | intent(in) | :: | sigma |
distribution dispersion/scale (must be positive) |
||
character(len=*), | intent(in) | :: | tail |
tail options |
returned probability integral
elemental function f_dst_gpd_cdf_core(x, xi, mu, sigma, tail) result(p) ! ==== Description !! Cumulative distribution function for generalised pareto distribution. ! ==== Declarations real(wp) , intent(in) :: x !! sample position real(wp) , intent(in) :: xi !! distribution shape parameter real(wp) , intent(in) :: mu !! distribution location real(wp) , intent(in) :: sigma !! distribution dispersion/scale (must be positive) character(len=*), intent(in) :: tail !! tail options real(wp) :: z !! z-score real(wp) :: p !! returned probability integral ! ==== Instructions ! ---- compute CDF ! compute z-score z = (x - mu) / sigma ! compute integral (left tailed) if (xi .eq. 0.0_wp) then if (z .lt. 0.0_wp) then p = 0.0_wp else p = 1.0_wp - exp(-z) end if else if (z .lt. 0.0_wp .or. & & (xi .lt. 0.0_wp .and. z .gt. -1.0_wp / xi)) then p = 0.0_wp else p = 1.0_wp - (1.0_wp + xi * z) ** (-1.0_wp / xi) endif endif ! tail options select case(tail) ! left-tailed; P(z<x) case("left") p = p ! right-tailed; P(z>x) case("right") p = 1.0_wp - p end select end function f_dst_gpd_cdf_core