Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
- setFreq :: Eq a => Frequency a -> a -> Int -> Frequency a
- nullFreq :: Frequency a -> Bool
- runFrequency :: Frequency a -> [(Int, a)]
- nameFrequency :: Frequency a -> Text
- minFreq :: Ord a => Frequency a -> Maybe a
- maxFreq :: Ord a => Frequency a -> Maybe a
- mostFreq :: Frequency a -> Maybe a
- meanFreq :: Frequency Int -> Int
The Frequency
type
The frequency distribution type. Not normalized (operations may or may not group the same elements and sum their frequencies). However, elements with zero frequency are removed upon construction.
The Eq
instance compares raw representations, not relative,
normalized frequencies, so operations don't need to preserve
the expected equalities, unless they do some kind of normalization
(see Dice
).
Monad Frequency Source # | |
Functor Frequency Source # | |
Applicative Frequency Source # | |
Foldable Frequency Source # | |
Traversable Frequency Source # | |
Alternative Frequency Source # | |
MonadPlus Frequency Source # | |
Eq a => Eq (Frequency a) Source # | |
Ord a => Ord (Frequency a) Source # | |
Show a => Show (Frequency a) Source # | |
Generic (Frequency a) Source # | |
Binary a => Binary (Frequency a) Source # | |
NFData a => NFData (Frequency a) Source # | |
Hashable a => Hashable (Frequency a) Source # | |
type Rep (Frequency a) Source # | |
Construction
uniformFreq :: Text -> [a] -> Frequency a Source #
Uniform discrete frequency distribution.
toFreq :: Text -> [(Int, a)] -> Frequency a Source #
Takes a name and a list of frequencies and items into the frequency distribution.
Transformation
scaleFreq :: Show a => Int -> Frequency a -> Frequency a Source #
Scale frequency distribution, multiplying it by a positive integer constant.
Consumption
runFrequency :: Frequency a -> [(Int, a)] Source #
give acces to raw frequency values
nameFrequency :: Frequency a -> Text Source #
short description for debug, etc.; keep it lazy, because it's rarely used