Safe Haskell | None |
---|

A list of items with relative frequencies of appearance.

- data Frequency a
- uniformFreq :: Text -> [a] -> Frequency a
- toFreq :: Text -> [(Int, a)] -> Frequency a
- scaleFreq :: Show a => Int -> Frequency a -> Frequency a
- renameFreq :: Text -> Frequency a -> Frequency a
- rollFreq :: Show a => Frequency a -> StdGen -> (a, StdGen)
- nullFreq :: Frequency a -> Bool
- runFrequency :: Frequency a -> [(Int, a)]
- nameFrequency :: Frequency a -> Text

# The `Frequency`

type

The frequency distribution type.

# Construction

uniformFreq :: Text -> [a] -> Frequency aSource

Uniform discrete frequency distribution.

toFreq :: Text -> [(Int, a)] -> Frequency aSource

Takes a name and a list of frequencies and items into the frequency distribution.

# Transformation

scaleFreq :: Show a => Int -> Frequency a -> Frequency aSource

Scale frequecy distribution, multiplying it by a positive integer constant.

renameFreq :: Text -> Frequency a -> Frequency aSource

Change the description of the frequency.

# Consumption

rollFreq :: Show a => Frequency a -> StdGen -> (a, StdGen)Source

Randomly choose an item according to the distribution.

runFrequency :: Frequency a -> [(Int, a)]Source

give acces to raw frequency values

nameFrequency :: Frequency a -> TextSource

short description for debug, etc.