f_dst_llogistic_cdf Function

public impure function f_dst_llogistic_cdf(x, alpha, beta, loc, tail) result(p)

Impure wrapper function for f_dst_llogistic_cdf_core. Handles optional arguments and invalid values for arguments.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

sample position

real(kind=wp), intent(in), optional :: alpha

distribution log-scale

real(kind=wp), intent(in), optional :: beta

distribution shape

real(kind=wp), intent(in), optional :: loc

distribution log-location

character(len=*), intent(in), optional :: tail

tail options

Return Value real(kind=wp)


Calls

proc~~f_dst_llogistic_cdf~~CallsGraph proc~f_dst_llogistic_cdf f_dst_llogistic_cdf proc~f_dst_llogistic_cdf_core f_dst_llogistic_cdf_core proc~f_dst_llogistic_cdf->proc~f_dst_llogistic_cdf_core proc~f_utl_assign_nan f_utl_assign_nan proc~f_dst_llogistic_cdf->proc~f_utl_assign_nan proc~s_err_print s_err_print proc~f_dst_llogistic_cdf->proc~s_err_print

Called by

proc~~f_dst_llogistic_cdf~~CalledByGraph proc~f_dst_llogistic_cdf f_dst_llogistic_cdf interface~fsml_llogistic_cdf fsml_llogistic_cdf interface~fsml_llogistic_cdf->proc~f_dst_llogistic_cdf

Source Code

impure function f_dst_llogistic_cdf(x, alpha, beta, loc, tail) result(p)

! ==== Description
!! Impure wrapper function for `f_dst_llogistic_cdf_core`.
!! Handles optional arguments and invalid values for arguments.

! ==== Declarations
  real(wp)        , intent(in)           :: x       !! sample position
  real(wp)        , intent(in), optional :: alpha   !! distribution log-scale
  real(wp)        , intent(in), optional :: beta    !! distribution shape
  real(wp)        , intent(in), optional :: loc     !! distribution log-location
  character(len=*), intent(in), optional :: tail    !! tail options
  real(wp)                               :: loc_w   !! final value of loc
  real(wp)                               :: alpha_w !! final value of alpha
  real(wp)                               :: beta_w  !! final value of beta
  character(len=16)                      :: tail_w  !! final tail option
  real(wp)                               :: p

! ==== Instructions

  ! assume alpha = 1, overwrite if specified
  alpha_w = 1.0_wp
  if (present(alpha)) alpha_w = alpha

  ! assume shape = 1, overwrite if specified
  beta_w = 1.0_wp
  if (present(beta)) beta_w = beta

  ! assume log-location = 0, overwrite if specified
  loc_w = 0.0_wp
  if (present(loc)) loc_w = loc

  ! assume left-tailed, overwrite if specified
  tail_w = "left"
  if (present(tail)) tail_w = tail

  ! check if alpha and shape values are valid
  if (alpha_w .le. 0.0_wp .or. beta_w .le. 0.0_wp) then
     call s_err_print(fsml_error(1))
     p = f_utl_assign_nan()
     return
  endif

  ! check if tail options are valid
  if (tail_w .ne. "left" .and. tail_w .ne. "right" .and. &
     &tail_w .ne. "two"  .and. tail_w .ne. "confidence") then
     call s_err_print(fsml_error(2))
     p = f_utl_assign_nan()
     return
  endif

  ! check if x value is valid (support x > 0)
  if (x .le. 0.0_wp) then
     if (tail_w .eq. "left") then
        p = 0.0_wp
     else if (tail_w .eq. "right") then
        p = 1.0_wp
     else
        p = 0.0_wp
     endif
     return
  endif

! ---- compute CDF

  ! call pure function to calculate probability integral
  p = f_dst_llogistic_cdf_core(x, alpha_w, beta_w, loc_w, tail_w)

end function f_dst_llogistic_cdf