sampling-0.3.2: Sample values from collections.

Safe HaskellNone
LanguageHaskell2010

Numeric.Sampling

Contents

Synopsis

Without replacement

sample :: (PrimMonad m, Foldable f) => Int -> f a -> Gen (PrimState m) -> m (Maybe [a]) Source #

(O(n)) Sample uniformly, without replacement.

Returns Nothing if the desired sample size is larger than the collection being sampled from.

sampleIO :: Foldable f => Int -> f a -> IO (Maybe [a]) Source #

(O(n)) sample specialized to IO.

With replacement

resample :: (PrimMonad m, Foldable f) => Int -> f a -> Gen (PrimState m) -> m [a] Source #

(O(n log n)) Sample uniformly with replacement (bootstrap).

resampleIO :: Foldable f => Int -> f a -> IO [a] Source #

(O(n log n)) resample specialized to IO.

Unequal probability, without replacement

psample :: (PrimMonad m, Foldable f) => Int -> f (Double, a) -> Gen (PrimState m) -> m (Maybe [a]) Source #

(O(n log n)) Unequal probability sampling.

Returns Nothing if the desired sample size is larger than the collection being sampled from.

psampleIO :: Foldable f => Int -> f (Double, a) -> IO (Maybe [a]) Source #

(O(n log n)) psample specialized to IO.

Unequal probability, with replacement

presample :: (PrimMonad m, Foldable f) => Int -> f (Double, a) -> Gen (PrimState m) -> m [a] Source #

(O(n log n)) Unequal probability resampling.

presampleIO :: Foldable f => Int -> f (Double, a) -> IO [a] Source #

(O(n log n)) presample specialized to IO.

Re-exported