Probability density function for gamma distribution.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x |
sample position |
||
real(kind=wp), | intent(in) | :: | alpha |
shape parameter |
||
real(kind=wp), | intent(in) | :: | beta |
scale parameter |
||
real(kind=wp), | intent(in) | :: | loc |
location parameter |
elemental function f_dst_gamma_pdf_core(x, alpha, beta, loc) result(fx) ! ==== Description !! Probability density function for gamma distribution. ! ==== Declarations real(wp), intent(in) :: x !! sample position real(wp), intent(in) :: alpha !! shape parameter real(wp), intent(in) :: beta !! scale parameter real(wp), intent(in) :: loc !! location parameter real(wp) :: z !! shifted and scaled variable real(wp) :: fx ! ==== Instructions ! ---- compute PDF ! calculate probability/fx if (x .le. 0.0_wp .or. alpha .le. 0.0_wp .or. beta .le. 0.0_wp) then fx = 0.0_wp else z = (x - loc) / beta fx = ( x ** (alpha - 1.0_wp) ) * exp( -z) / & & ( beta ** alpha * gamma(alpha)) endif end function f_dst_gamma_pdf_core