monus-weighted-search-0.2.0.0: Efficient search weighted by an ordered monoid with monus.
Copyright(c) Donnacha Oisín Kidney 2021
Maintainermail@doisinkidney.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

MonusWeightedSearch.Examples.Sampling

Description

Random sampling from the Heap monad.

The Heap monad can function as a probability monad, and it implements an efficient sampling algorithm, based on reservoir sampling.

Synopsis

Documentation

withChance :: Integral a => Ratio a -> IO Bool Source #

withChance p returns True p percent of the time.

sample :: Heap Prob a -> IO a Source #

Sample a single value from the heap.