commit fdc5e0e84a5fc96176e0e9203b4fa65741f381de
parent 9f085d55a22c114075be0787b2698e46e013b184
Author: Marco Zocca <marco.zocca@recordunion.com>
Date: Tue, 30 Jan 2018 16:20:41 +0100
add Normal-Gamma, Pareto, bump to 2.0.1
Diffstat:
3 files changed, 14 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,14 @@ 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
+
-- | The Dirichlet distribution.
dirichlet
:: (Traversable f, PrimMonad m) => f Double -> Prob m (f Double)