f_dst_logistic_pdf_core Function

public elemental function f_dst_logistic_pdf_core(x, mu, scale) result(fx)

Probability density function for logistic distribution.

Arguments

Type IntentOptional 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

Return Value real(kind=wp)


Called by

proc~~f_dst_logistic_pdf_core~~CalledByGraph proc~f_dst_logistic_pdf_core f_dst_logistic_pdf_core proc~f_dst_logistic_pdf f_dst_logistic_pdf proc~f_dst_logistic_pdf->proc~f_dst_logistic_pdf_core interface~fsml_logistic_pdf fsml_logistic_pdf interface~fsml_logistic_pdf->proc~f_dst_logistic_pdf

Source Code

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