mwc-probability

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

commit 1430771f0359a7f1be709069f0ff6a3e06997042
parent dacffb5e45f3db4c62d308971afecef7e0fc8fcc
Author: Marco Zocca <ocramz>
Date:   Mon, 20 Jan 2020 16:52:28 +0100

improve docs

Diffstat:
Msrc/System/Random/MWC/Probability.hs | 14++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/System/Random/MWC/Probability.hs b/src/System/Random/MWC/Probability.hs @@ -454,20 +454,22 @@ zipf a = do -- * Chinese Restaurant process --- | Pitman-Yor process + +-- | Pitman-Yor process +-- +-- This implementation is given in terms of the Chinese Restaurant process pitmanYor :: (PrimMonad f) => Double -- ^ a \in [0, 1] -> Double -- ^ b > 0 - -> Int -- ^ number of samples - -> Gen (PrimState f) - -> f [Integer] -pitmanYor a b n gen = do + -> Int -- ^ Total number of customers entering the Chinese Restaurant + -> Prob f [Integer] +pitmanYor a b n = do ts <- go crpInitial (n - 1) pure $ map getSum $ customers ts where go acc 0 = pure acc go acc i = do - acc' <- sample (pitmanYorSingle a b acc) gen + acc' <- pitmanYorSingle a b acc go acc' (i - 1) pitmanYorSingle :: (PrimMonad m, Integral a) =>