| 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)
- shuffle :: [a] -> StdGen -> [a]
- randomByteStringR :: (Int, Int) -> StdGen -> (ByteString, StdGen)
- splitGen_compat :: StdGen -> (StdGen, StdGen)
- uniform_compat :: (Uniform a, RandomGen g) => g -> (a, g)
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.
Shuffling
shuffle :: [a] -> StdGen -> [a] Source #
Create a random permutation of a list.
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.
Compatibility
splitGen_compat :: StdGen -> (StdGen, StdGen) Source #
Alternative to splitGen that is also compatible with versions of
random<1.3
Uses split on random<1.3, and splitGen on random>=1.3. The former
function is deprecated on random>=1.3.
uniform_compat :: (Uniform a, RandomGen g) => g -> (a, g) Source #
Alternative to uniform that is also compatible with versions of
random<1.3
The order of type variables is different on randomand random=1.3. This is inconvenient for type application, so we use this compatibility function to ensure that the type variables always have the same ordering.