Impure wrapper function for f_dst_chi2_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 and 1.0 |
||
real(kind=wp), | intent(in) | :: | df |
degrees of freedom |
||
real(kind=wp), | intent(in), | optional | :: | loc |
location parameter |
|
real(kind=wp), | intent(in), | optional | :: | scale |
scale parameter |
sample position
impure function f_dst_chi2_ppf(p, df, loc, scale) result(x) ! ==== Description !! Impure wrapper function for `f_dst_chi2_ppf_core`. !! Handles optional arguments and invalid values for arguments. ! ==== Declarations real(wp), intent(in) :: p !! probability between 0.0 and 1.0 real(wp), intent(in) :: df !! degrees of freedom real(wp), intent(in), optional :: loc !! location parameter real(wp), intent(in), optional :: scale !! scale parameter real(wp) :: loc_w !! final value for loc real(wp) :: scale_w !! final value for scale real(wp) :: x !! sample position ! ==== Instructions ! ---- handle input ! assume loc = 0, overwrite if specified loc_w = 0.0_wp if (present(loc)) loc_w = loc ! 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 sentinel value if invalid call s_err_print(fsml_error(1)) x = c_sentinel_r return endif ! check if degrees of freedom value is valid if (df .le. 0.0_wp) then ! write error message and assign sentinel value if invalid call s_err_print(fsml_error(1)) x = c_sentinel_r return endif ! check if p value is valid if (p .gt. 1.0_wp .or. p .lt. 0.0_wp) then ! write error message and assign sentinel value if invalid call s_err_print(fsml_error(1)) x = c_sentinel_r return endif ! ---- compute PPF ! call pure function to calculate x x = f_dst_chi2_ppf_core(p, df, loc_w, scale_w) ! issue warning in case of suspicious result if (x .eq. c_sentinel_r) call s_err_warn(fsml_warning(1)) end function f_dst_chi2_ppf