lsm-tree-0.1.0.0: Log-structured merge-trees
Safe HaskellSafe-Inferred
LanguageGHC2021

Database.LSMTree.Extras.Random

Synopsis

Sampling from uniform distributions

withoutReplacement :: Ord a => StdGen -> Int -> (StdGen -> (a, StdGen)) -> [a] Source #

withReplacement :: StdGen -> Int -> (StdGen -> (a, StdGen)) -> [a] Source #

Sampling from multiple distributions

frequency :: [(Int, StdGen -> (a, StdGen))] -> StdGen -> (a, StdGen) Source #

Chooses one of the given generators, with a weighted random distribution. The input list must be non-empty, weights should be non-negative, and the sum of weights should be non-zero (i.e., at least one weight should be positive).

Based on the implementation in QuickCheck.

Generators for specific data types

randomByteStringR :: (Int, Int) -> StdGen -> (ByteString, StdGen) Source #

Generates a random bytestring. Its length is uniformly distributed within the provided range.