mwc-probability

Sampling function-based probability distributions.
Log | Files | Refs | README | LICENSE

commit 909cb087a030b925403887a7c53c15d559e4fd6a
parent dad9cf7892100821b43a24f770be8e49826dd876
Author: Marco Zocca <ocramz@users.noreply.github.com>
Date:   Thu, 10 May 2018 08:10:28 +0200

Fixed typos in inverseGaussian
Diffstat:
Msrc/System/Random/MWC/Probability.hs | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/System/Random/MWC/Probability.hs b/src/System/Random/MWC/Probability.hs @@ -337,17 +337,18 @@ isoNormal ms sd = traverse (`normal` sd) ms -- | The inverse Gaussian (also known as Wald) distribution. -- --- Both the mean parameter 'my' and the shape parameter 'lambda' must be positive. +-- Both the mean parameter 'mu' and the shape parameter 'lambda' must be positive. inverseGaussian :: PrimMonad m => Double -> Double -> Prob m Double -inverseGaussian lambda my = do +inverseGaussian lambda mu = do nu <- standardNormal let y = nu ** 2 - x = my + 1 / (2 * lambda) * (my ** 2 * y + my * sqrt (4 * my * lambda * y) + my ** 2 * y ** 2) - thresh = my / (my + x) + s = sqrt (4 * mu * lambda * y + mu ** 2 * y ** 2) + x = mu * (1 + 1 / (2 * lambda) * (mu * y - s)) + thresh = mu / (mu + x) z <- uniform if z <= thresh then return x - else return (my ** 2 / x) + else return (mu ** 2 / x) {-# INLINABLE inverseGaussian #-}