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
- setFreq :: Eq a => Frequency a -> a -> Int -> Frequency a
- nullFreq :: Frequency a -> Bool
- runFrequency :: Frequency a -> [(Int, a)]
- nameFrequency :: Frequency a -> Text
- maxFreq :: (Show a, Ord a) => Frequency a -> a
- minFreq :: (Show a, Ord a) => Frequency a -> a
- meanFreq :: (Show a, Integral a) => Frequency a -> Rational

# The `Frequency`

type

The frequency distribution type. Not normalized (operations may or may not group the same elements and sum their frequencies).

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 | |

Functor Frequency | |

Num SimpleDice | |

MonadPlus Frequency | |

Applicative Frequency | |

Foldable Frequency | |

Traversable Frequency | |

Alternative Frequency | |

Eq a => Eq (Frequency a) | |

Ord a => Ord (Frequency a) | |

Read a => Read (Frequency a) | |

Show a => Show (Frequency a) | |

Generic (Frequency a) | |

Binary a => Binary (Frequency a) | |

Hashable a => Hashable (Frequency a) |

# 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

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

give acces to raw frequency values

nameFrequency :: Frequency a -> TextSource

short description for debug, etc.; keep it lazy, because it's rarely used