Cumulative distribution function for logistic distribution.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | x |
sample position |
||
| real(kind=wp), | intent(in) | :: | mu |
distribution location |
||
| real(kind=wp), | intent(in) | :: | scale |
distribution scale |
||
| character(len=*), | intent(in) | :: | tail |
tail options |
elemental function f_dst_logistic_cdf_core(x, mu, scale, tail) result(p) ! ==== Description !! Cumulative distribution function for logistic distribution. ! ==== Declarations real(wp) , intent(in) :: x !! sample position real(wp) , intent(in) :: mu !! distribution location real(wp) , intent(in) :: scale !! distribution scale character(len=*), intent(in) :: tail !! tail options real(wp) :: z !! z-score real(wp) :: p ! ==== Instructions ! compute z-score z = (x - mu) / scale ! compute integral (left tailed); partition by z for numerical stability if (z .ge. 0.0_wp) then p = 1.0_wp / (1.0_wp + exp(-z)) else p = exp(z) / (1.0_wp + exp(z)) 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 ! two-tailed case("two") if (x .gt. mu) then p = 2.0_wp * (1.0_wp - p) else p = 2.0_wp * p endif ! confidence interval case("confidence") if (x .gt. mu) then p = 1.0_wp - 2.0_wp * (1.0_wp - p) else p = 1.0_wp - 2.0_wp * p endif end select end function f_dst_logistic_cdf_core