Distributions.jl
Distributions.jl copied to clipboard
Add mean et al. for truncated log normal
This PR adds mgf for truncated normal and uses that to implement mean, var, skewness, and kurtosis for truncated log normal based on this observation. ~~median is also implemented for truncated log normal.~~
Fixes #709
My worry (that was also expressed in issues such as https://github.com/JuliaStats/Distributions.jl/issues/968) is that generally numerical integration is challenging and a fallback might lead to silently incorrect results. It seems such a fallback would be wrong (or at least problematic) e.g. if the moments are not finite (such as e.g. for Cauchy).
So my general feeling is that numerical integration should maybe be restricted to a smaller subset of distributions, or maybe even only be available as a separate function. In case we want to use it more broadly, I think it would also be safer to error if the integration error estimate is too large, to reduce the probability of silently incorrect results.
@devmotion Is there any numerical integration in this code?
@devmotion, perhaps you're thinking of #1875? As @PaulSoderlind noted, there's no integration here.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 85.71%. Comparing base (
65f056c) to head (70c7810). Report is 3 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #1874 +/- ##
==========================================
- Coverage 85.99% 85.71% -0.29%
==========================================
Files 144 145 +1
Lines 8666 8706 +40
==========================================
+ Hits 7452 7462 +10
- Misses 1214 1244 +30
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Oh yes, indeed, it seems I commented on the wrong PR.
CI failures on nightly are unrelated.
Ugh, type inference issue on 1.3 and I can't test on 1.3 locally 😑