hakaru-0.1.4: A probabilistic programming embedded DSL

Safe HaskellNone



Functions on lists and sequences. Some of the functions follow the style of Data.Random.Extras (from the random-extras package), but are written for use with PRNGs from the "mwc-random" package rather than from the "random-fu" package.



extract :: Seq a -> Int -> Maybe (Seq a, a) Source

randomExtract :: Seq a -> GenIO -> IO (Maybe (Seq a, a)) Source

randomElems :: Ord a => Seq a -> Int -> IO (Seq a) Source

Given a sequence, return a *sorted* sequence of n randomly selected elements from *distinct positions* in the sequence

randomElemsTR :: Ord a => Seq a -> Seq a -> GenIO -> Int -> IO (Seq a) Source

pieces :: Seq a -> Seq Int -> [Seq a] Source

Chop a sequence at the given indices. Assume number of indices given < length of sequence to be chopped

randomPieces :: Int -> Seq a -> IO [Seq a] Source

Given n, chop a sequence at m random points where m = min (length-1, n-1)

pairs :: [a] -> [(a, a)] Source

pairs [1,2,3,4]
> pairs [1,2,4,4]

l2Norm :: Floating a => [a] -> a Source