diff --git a/src/univariate/continuous/inversegaussian.jl b/src/univariate/continuous/inversegaussian.jl index 443f8fd5f..63cbe0928 100644 --- a/src/univariate/continuous/inversegaussian.jl +++ b/src/univariate/continuous/inversegaussian.jl @@ -102,7 +102,7 @@ function cdf(d::InverseGaussian, x::Real) # 2λ/μ and normlogcdf(-u*(v+1)) are similar magnitude, opp. sign # truncating to [0, 1] as an additional precaution # Ref https://github.com/JuliaStats/Distributions.jl/issues/1873 - z = clamp(normcdf(u * (v - 1)) + exp(2λ / μ + normlogcdf(-u * (v + 1)), 0, 1) + z = clamp(normcdf(u * (v - 1)) + exp(2λ / μ + normlogcdf(-u * (v + 1)), 0, 1)) # otherwise `NaN` is returned for `+Inf` return isinf(x) && x > 0 ? one(z) : z @@ -116,7 +116,7 @@ function ccdf(d::InverseGaussian, x::Real) # 2λ/μ and normlogcdf(-u*(v+1)) are similar magnitude, opp. sign # truncating to [0, 1] as an additional precaution # Ref https://github.com/JuliaStats/Distributions.jl/issues/1873 - z = clamp(normccdf(u * (v - 1)) - exp(2λ / μ + normlogcdf(-u * (v + 1)), 0, 1) + z = clamp(normccdf(u * (v - 1)) - exp(2λ / μ + normlogcdf(-u * (v + 1)), 0, 1)) # otherwise `NaN` is returned for `+Inf` return isinf(x) && x > 0 ? zero(z) : z