f_dst_chi2_pdf_core Function

public elemental function f_dst_chi2_pdf_core(x, df, loc, scale) result(fx)

Probability density 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

Return Value real(kind=wp)

resulting PDF value


Called by

proc~~f_dst_chi2_pdf_core~~CalledByGraph proc~f_dst_chi2_pdf_core f_dst_chi2_pdf_core proc~f_dst_chi2_pdf f_dst_chi2_pdf proc~f_dst_chi2_pdf->proc~f_dst_chi2_pdf_core interface~fsml_chi2_pdf fsml_chi2_pdf interface~fsml_chi2_pdf->proc~f_dst_chi2_pdf

Source Code

elemental function f_dst_chi2_pdf_core(x, df, loc, scale) result(fx)

! ==== Description
!! Probability density 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
  real(wp)             :: z       !! standardised variable
  real(wp)             :: fx      !! resulting PDF value

! ==== Instructions

! ----compute PDF
  z = (x - loc) / scale
  if (z .le. 0.0_wp .or. df .le. 0.0_wp .or. scale .le. 0.0_wp) then
     fx = 0.0_wp
  else
     fx = (1.0_wp / (2.0_wp ** (df / 2.0_wp) * &
        & gamma(df / 2.0_wp) * scale)) * &
        & z ** (df / 2.0_wp - 1.0_wp) * exp(-z / 2.0_wp)
  endif

end function f_dst_chi2_pdf_core