f_dst_t_cdf_core Function

public elemental function f_dst_t_cdf_core(x, df, mu, sigma, tail) result(p)

Cumulative distribution function for student t 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) :: mu

distribution location (mean)

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

distribution dispersion/scale (standard deviation)

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

tail options

Return Value real(kind=wp)

returned probability integral


Calls

proc~~f_dst_t_cdf_core~~CallsGraph proc~f_dst_t_cdf_core f_dst_t_cdf_core proc~f_dst_betai_core f_dst_betai_core proc~f_dst_t_cdf_core->proc~f_dst_betai_core

Called by

proc~~f_dst_t_cdf_core~~CalledByGraph proc~f_dst_t_cdf_core f_dst_t_cdf_core proc~f_dst_t_cdf f_dst_t_cdf proc~f_dst_t_cdf->proc~f_dst_t_cdf_core proc~f_dst_t_ppf_core f_dst_t_ppf_core proc~f_dst_t_ppf_core->proc~f_dst_t_cdf_core proc~s_tst_ttest_1s_core s_tst_ttest_1s_core proc~s_tst_ttest_1s_core->proc~f_dst_t_cdf_core proc~s_tst_ttest_2s_core s_tst_ttest_2s_core proc~s_tst_ttest_2s_core->proc~f_dst_t_cdf_core interface~fsml_t_cdf fsml_t_cdf interface~fsml_t_cdf->proc~f_dst_t_cdf proc~f_dst_t_ppf f_dst_t_ppf proc~f_dst_t_ppf->proc~f_dst_t_ppf_core proc~s_tst_ttest_1s s_tst_ttest_1s proc~s_tst_ttest_1s->proc~s_tst_ttest_1s_core proc~s_tst_ttest_2s s_tst_ttest_2s proc~s_tst_ttest_2s->proc~s_tst_ttest_2s_core proc~s_tst_ttest_paired_core s_tst_ttest_paired_core proc~s_tst_ttest_paired_core->proc~s_tst_ttest_1s_core interface~fsml_t_ppf fsml_t_ppf interface~fsml_t_ppf->proc~f_dst_t_ppf interface~fsml_ttest_1sample fsml_ttest_1sample interface~fsml_ttest_1sample->proc~s_tst_ttest_1s interface~fsml_ttest_2sample fsml_ttest_2sample interface~fsml_ttest_2sample->proc~s_tst_ttest_2s proc~s_tst_ttest_paired s_tst_ttest_paired proc~s_tst_ttest_paired->proc~s_tst_ttest_paired_core interface~fsml_ttest_paired fsml_ttest_paired interface~fsml_ttest_paired->proc~s_tst_ttest_paired

Source Code

elemental function f_dst_t_cdf_core(x, df, mu, sigma, tail) result(p)

! ==== Description
!! Cumulative distribution function for student t distribution.

! ==== Declarations
  real(wp)        , intent(in) :: x           !! sample position
  real(wp)        , intent(in) :: df          !! degrees of freedom
  real(wp)        , intent(in) :: mu          !! distribution location (mean)
  real(wp)        , intent(in) :: sigma       !! distribution dispersion/scale (standard deviation)
  character(len=*), intent(in) :: tail        !! tail options
  real(wp)                     :: z           !! z-score
  real(wp)                     :: xbeta, a, b !! parameters for beta function
  real(wp)                     :: p           !! returned probability integral

! ==== Instructions

! ---- compute CDF

  ! compute z-score
  z = (x - mu) / sigma

  ! shape parameters for beta function
  a = 0.5_wp * df
  b = 0.5_wp
  xbeta = df / (df + z**2)

  ! compute integral (left tailed)
  if (z .ge. 0.0_wp) then
    p = 1.0_wp - 0.5_wp * f_dst_betai_core(xbeta, a, b)
  else
    p = 0.5_wp * f_dst_betai_core(xbeta, a, b)
  endif

  ! tail options
  ! NOTE: alternatively, compare z to 0.0 instead of x to mu
  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. mu) then
           p = 2.0_wp * (1.0_wp - p)
        elseif (x .le. mu) then
           p = 2.0_wp * p
        endif
     ! confidence interval
     case("confidence")
        if (x .gt. mu) then
           p = 1.0_wp - 2.0_wp * (1.0_wp - p)
        elseif (x .le. mu) then
           p = 1.0_wp - 2.0_wp * p
        endif
   end select

end function f_dst_t_cdf_core