Probability density 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 |
elemental function f_dst_logistic_pdf_core(x, mu, scale) result(fx) ! ==== Description !! Probability density 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 real(wp) :: z !! z-score real(wp) :: p !! probability from CDF real(wp) :: fx ! ==== Instructions ! compute z-score z = (x - mu) / scale ! CDF evaluation 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 ! calculate probability/fx fx = (p * (1.0_wp - p)) / scale ! NOTE: mathematically more intuitive, but less stable: ! ez = exp(-z) ! fx = ez / (scale * (1.0_wp + ez)**2) end function f_dst_logistic_pdf_core