mwc-probability

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

commit e0b267c4ad589012bcbdb631401e184799db10f3
parent 92bd48531642c277923c6615a2e018ff2963ea70
Author: Jared Tobin <jared@jtobin.ca>
Date:   Sun,  4 Dec 2016 22:01:18 +1300

Generalize to Traversable in couple of locations.

Minor version bump (1.3.0).

Diffstat:
ACHANGELOG | 6++++++
Mmwc-probability.cabal | 6+++---
Msrc/System/Random/MWC/Probability.hs | 9+++++----
Mstack-travis.yaml | 2+-
Mstack.yaml | 2+-
5 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG @@ -0,0 +1,6 @@ +# Changelog + +- 1.3.0 (2016-12-04) + * Generalize a couple of samplers to use Traversable rather than lists. + + diff --git a/mwc-probability.cabal b/mwc-probability.cabal @@ -1,5 +1,5 @@ name: mwc-probability -version: 1.2.2 +version: 1.3.0 homepage: http://github.com/jtobin/mwc-probability license: MIT license-file: LICENSE @@ -53,6 +53,6 @@ library build-depends: base > 4 && < 6 , mwc-random > 0.13 && < 0.14 - , primitive - , transformers + , primitive >= 0.6 && < 1.0 + , transformers >= 0.5 && < 1.0 diff --git a/src/System/Random/MWC/Probability.hs b/src/System/Random/MWC/Probability.hs @@ -219,9 +219,9 @@ beta a b = do -- | The Dirichlet distribution. dirichlet - :: (Foldable f, PrimMonad m) => f Double -> Prob m [Double] + :: (Traversable f, PrimMonad m) => f Double -> Prob m (f Double) dirichlet as = do - zs <- mapM (`gamma` 1) (F.toList as) + zs <- traverse (`gamma` 1) as return $ fmap (/ sum zs) zs {-# INLINABLE dirichlet #-} @@ -258,8 +258,9 @@ student m s k = do {-# INLINABLE student #-} -- | An isotropic or spherical Gaussian distribution. -isoGauss :: (Foldable f, PrimMonad m) => f Double -> Double -> Prob m [Double] -isoGauss ms sd = mapM (`normal` sd) (F.toList ms) +isoGauss + :: (Traversable f, PrimMonad m) => f Double -> Double -> Prob m (f Double) +isoGauss ms sd = traverse (`normal` sd) ms {-# INLINABLE isoGauss #-} -- | The Poisson distribution. diff --git a/stack-travis.yaml b/stack-travis.yaml @@ -2,7 +2,7 @@ flags: {} packages: - '.' extra-deps: [] -resolver: lts-7.0 +resolver: lts-7.11 compiler: ghc-8.0.1 system-ghc: false install-ghc: true diff --git a/stack.yaml b/stack.yaml @@ -2,4 +2,4 @@ flags: {} packages: - '.' extra-deps: [] -resolver: lts-7.0 +resolver: lts-7.11