mwc-probability

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

commit 85e50c05844677201ae38e4ea66da2ffb306c15a
parent 5fca576e31eb45333966ce0aaa581d9c28b95b1b
Author: Jared Tobin <jared@jtobin.ca>
Date:   Fri, 10 Apr 2015 14:02:13 +1200

Add t, isoGauss samplers.

Diffstat:
Mmwc-probability.cabal | 2+-
Msrc/System/Random/MWC/Probability.hs | 12++++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/mwc-probability.cabal b/mwc-probability.cabal @@ -1,5 +1,5 @@ name: mwc-probability -version: 0.2.0.1 +version: 0.3.1.0 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 @@ -19,6 +19,8 @@ module System.Random.MWC.Probability ( , bernoulli , binomial , multinomial + , t + , isoGauss ) where import Control.Applicative @@ -130,3 +132,13 @@ multinomial n ps = do return g {-# INLINE multinomial #-} +t :: PrimMonad m => Double -> Double -> Double -> Prob m Double +t m s k = do + sd <- sqrt <$> inverseGamma (k / 2) (s * 2 / k) + normal m sd +{-# INLINE t #-} + +isoGauss :: PrimMonad m => [Double] -> Double -> Prob m [Double] +isoGauss ms sd = mapM (\m -> normal m sd) ms +{-# INLINE isoGauss #-} +