f_dst_chi2_cdf_core Function

public elemental function f_dst_chi2_cdf_core(x, df, loc, scale, tail) result(p)

Cumulative distribution function for the chi-squared distribution.

Arguments

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

sample position

real(kind=wp), intent(in) :: df

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 options

Return Value real(kind=wp)

resulting CDF value


Calls

proc~~f_dst_chi2_cdf_core~~CallsGraph proc~f_dst_chi2_cdf_core f_dst_chi2_cdf_core proc~f_dst_gammai_core f_dst_gammai_core proc~f_dst_chi2_cdf_core->proc~f_dst_gammai_core

Called by

proc~~f_dst_chi2_cdf_core~~CalledByGraph proc~f_dst_chi2_cdf_core f_dst_chi2_cdf_core proc~f_dst_chi2_cdf f_dst_chi2_cdf proc~f_dst_chi2_cdf->proc~f_dst_chi2_cdf_core proc~f_dst_chi2_ppf_core f_dst_chi2_ppf_core proc~f_dst_chi2_ppf_core->proc~f_dst_chi2_cdf_core proc~s_tst_kruskalwallis_core s_tst_kruskalwallis_core proc~s_tst_kruskalwallis_core->proc~f_dst_chi2_cdf_core interface~fsml_chi2_cdf fsml_chi2_cdf interface~fsml_chi2_cdf->proc~f_dst_chi2_cdf proc~f_dst_chi2_ppf f_dst_chi2_ppf proc~f_dst_chi2_ppf->proc~f_dst_chi2_ppf_core proc~s_tst_kruskalwallis s_tst_kruskalwallis proc~s_tst_kruskalwallis->proc~s_tst_kruskalwallis_core interface~fsml_chi2_ppf fsml_chi2_ppf interface~fsml_chi2_ppf->proc~f_dst_chi2_ppf interface~fsml_kruskalwallis fsml_kruskalwallis interface~fsml_kruskalwallis->proc~s_tst_kruskalwallis

Source Code

elemental function f_dst_chi2_cdf_core(x, df, loc, scale, tail) result(p)

! ==== Description
!! Cumulative distribution function for the chi-squared distribution.

  ! ==== Declarations
  real(wp)        , intent(in) :: x       !! sample position
  real(wp)        , intent(in) :: df      !! degrees of freedom
  real(wp)        , intent(in) :: loc     !! location parameter
  real(wp)        , intent(in) :: scale   !! scale parameter
  character(len=*), intent(in) :: tail    !! tail options
  real(wp)                     :: z       !! standardised variable
  real(wp)                     :: p       !! resulting CDF value

! ==== Instructions

! ----compute CDF

  ! compute integral (left tailed)
  z = (x - loc) / scale
  if (z .le. 0.0_wp .or. df .le. 0.0_wp .or. scale .le. 0.0_wp) then
     p = 0.0_wp
  else
     p = f_dst_gammai_core(df / 2.0_wp, z / 2.0_wp)
  endif

  ! 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 (x .gt. loc) then
           p = 2.0_wp * (1.0_wp - p)
        elseif (x .le. loc) then
           p = 2.0_wp * p
        endif
     ! confidence interval
     case("confidence")
        if (x .gt. loc) then
           p = 1.0_wp - 2.0_wp * (1.0_wp - p)
        elseif (x .le. loc) then
           p = 1.0_wp - 2.0_wp * p
        endif
   end select

end function f_dst_chi2_cdf_core