Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Database.LSMTree.Extras.Random
Synopsis
- uniformWithoutReplacement :: (Ord a, Uniform a) => StdGen -> Int -> [a]
- uniformWithReplacement :: Uniform a => StdGen -> Int -> [a]
- sampleUniformWithoutReplacement :: Ord a => StdGen -> Int -> [a] -> [a]
- sampleUniformWithReplacement :: Ord a => StdGen -> Int -> [a] -> [a]
- withoutReplacement :: Ord a => StdGen -> Int -> (StdGen -> (a, StdGen)) -> [a]
- withReplacement :: StdGen -> Int -> (StdGen -> (a, StdGen)) -> [a]
- frequency :: [(Int, StdGen -> (a, StdGen))] -> StdGen -> (a, StdGen)
- randomByteStringR :: (Int, Int) -> StdGen -> (ByteString, StdGen)
Sampling from uniform distributions
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.