Probability density function for the chi-squared distribution.
Type | Intent | Optional | 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 |
resulting PDF value
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