Impure wrapper function for f_dst_logistic_ppf_core.
Handles optional arguments and invalid values for arguments.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | p |
probability between 0.0 - 1.0 |
||
| real(kind=wp), | intent(in), | optional | :: | mu |
distribution location (mean) |
|
| real(kind=wp), | intent(in), | optional | :: | scale |
distribution scale |
impure function f_dst_logistic_ppf(p, mu, scale) result(x) ! ==== Description !! Impure wrapper function for `f_dst_logistic_ppf_core`. !! Handles optional arguments and invalid values for arguments. ! ==== Declarations real(wp), intent(in) :: p !! probability between 0.0 - 1.0 real(wp), intent(in), optional :: mu !! distribution location (mean) real(wp), intent(in), optional :: scale !! distribution scale real(wp) :: p_w !! final value of p real(wp) :: mu_w !! final value of mu real(wp) :: scale_w !! final value of scale real(wp) :: x ! ==== Instructions ! assume location/mean = 0, overwrite if specified mu_w = 0.0_wp if (present(mu)) mu_w = mu ! assume scale = 1, overwrite if specified scale_w = 1.0_wp if (present(scale)) scale_w = scale ! check if scale value is valid if (scale_w .le. 0.0_wp) then ! write error message and assign NaN value if invalid call s_err_print(fsml_error(1)) x = f_utl_assign_nan() return endif ! check if p value is valid if (p .le. 0.0_wp .or. p .ge. 1.0_wp) then ! write error message and assign NaN value if invalid call s_err_print(fsml_error(1)) x = f_utl_assign_nan() return endif ! ---- compute PPF ! for stability, set very small (large) numbers to epsilon (1-epsilon) p_w = min(max(p, c_eps), 1.0_wp - c_eps) ! call pure function to calculate x x = f_dst_logistic_ppf_core(p_w, mu_w, scale_w) ! issue warning in case of suspicious result if (f_utl_is_nan(x)) call s_err_warn(fsml_warning(1)) end function f_dst_logistic_ppf