Safe Haskell | None |
---|---|
Language | Haskell98 |
Documentation
randomElement :: [a] -> RVar a Source
A random variable returning an arbitrary element of the given list.
Every element has equal probability of being chosen. Because it is a
pure RVar
it has no memory - that is, it "draws with replacement."
randomElementT :: [a] -> RVarT m a Source
shuffle :: [a] -> RVar [a] Source
A random variable that returns the given list in an arbitrary shuffled order. Every ordering of the list has equal probability.
shuffleN :: Int -> [a] -> RVar [a] Source
A random variable that shuffles a list of a known length (or a list prefix of the specified length). Useful for shuffling large lists when the length is known in advance. Avoids needing to traverse the list to discover its length. Each ordering has equal probability.
shuffleNofM :: Int -> Int -> [a] -> RVar [a] Source
A random variable that selects N arbitrary elements of a list of known length M.
shuffleNofMT :: Int -> Int -> [a] -> RVarT m [a] Source