Cumulative density function for the F distribution.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x |
sample position |
||
real(kind=wp), | intent(in) | :: | d1 |
numerator degrees of freedom |
||
real(kind=wp), | intent(in) | :: | d2 |
denominator degrees of freedom |
||
real(kind=wp), | intent(in) | :: | loc |
location parameter |
||
real(kind=wp), | intent(in) | :: | scale |
scale parameter |
||
character(len=*), | intent(in) | :: | tail |
tail option |
output probability
elemental function f_dst_f_cdf_core(x, d1, d2, loc, scale, tail) result(p) ! ==== Description !! Cumulative density function for the F distribution. ! ==== Declarations real(wp) , intent(in) :: x !! sample position real(wp) , intent(in) :: d1 !! numerator degrees of freedom real(wp) , intent(in) :: d2 !! denominator degrees of freedom real(wp) , intent(in) :: loc !! location parameter real(wp) , intent(in) :: scale !! scale parameter character(len=*), intent(in) :: tail !! tail option real(wp) :: z !! standardised variable real(wp) :: xbeta !! beta variable real(wp) :: p !! output probability ! ==== Instructions ! ----compute CDF ! get z score (standardise) z = (x - loc) / scale ! z must be positive non-zero; return 0 if not if (z .le. 0.0_wp) then p = 0.0_wp return endif ! transform to beta domain xbeta = (d1 * z) / (d1 * z + d2) p = f_dst_betai_core(xbeta, 0.5_wp * d1, 0.5_wp * d2) ! tail options select case(tail) ! left-tailed; P(z<x) case("left") p = p ! right-tailed; P(z>x) case("right") p = 1.0_wp - p ! two-tailed case("two") if (z .lt. 1.0_wp) then p = 2.0_wp * p else p = 2.0_wp * (1.0_wp - p) endif ! confidence interval case("confidence") if (z .lt. 1.0_wp) then p = 1.0_wp - 2.0_wp * p else p = 1.0_wp - 2.0_wp * (1.0_wp - p) endif end select end function f_dst_f_cdf_core