commit f08cb4f9e10b68226fcaae2f3effb954f0aabd61
parent f9de400139e6e02c625168bd4c487a13e1a5156e
Author: Marco Zocca <ocramz@users.noreply.github.com>
Date: Tue, 30 Jan 2018 16:22:31 +0100
Merge pull request #9 from ocramz/master
Add Normal-Gamma, Pareto, bump to 2.0.1
Diffstat:
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
@@ -1,4 +1,7 @@
-# Changelog
+ # Changelog
+
+ - 2.0.1 (2018-01-30)
+ * Add Normal-Gamma and Pareto distributions
- 2.0.0 (2018-01-29)
* Add Laplace and Zipf-Mandelbrot distribution
diff --git a/mwc-probability.cabal b/mwc-probability.cabal
@@ -1,5 +1,5 @@
name: mwc-probability
-version: 2.0.0
+version: 2.0.1
homepage: http://github.com/jtobin/mwc-probability
license: MIT
license-file: LICENSE
diff --git a/src/System/Random/MWC/Probability.hs b/src/System/Random/MWC/Probability.hs
@@ -77,6 +77,7 @@ module System.Random.MWC.Probability (
, chiSquare
, beta
, student
+ , pareto
-- *** Dirichlet process
, dirichlet
, symmetricDirichlet
@@ -262,6 +263,15 @@ beta a b = do
return $ u / (u + w)
{-# INLINABLE beta #-}
+-- | The Pareto distribution with specified index `a` and minimum `xmin` parameters.
+--
+-- Both `a` and `xmin` must be positive.
+pareto :: PrimMonad m => Double -> Double -> Prob m Double
+pareto a xmin = do
+ y <- exponential a
+ return $ xmin * exp y
+{-# INLINABLE pareto #-}
+
-- | The Dirichlet distribution.
dirichlet
:: (Traversable f, PrimMonad m) => f Double -> Prob m (f Double)