random-fu-0.0.3.2: Random number generation

Data.Random.Distribution.Discrete

Synopsis

# Documentation

discrete :: Distribution (Discrete p) a => [(p, a)] -> RVar aSource

empirical :: (Num p, Ord a) => [a] -> Discrete p aSource

newtype Discrete p a Source

Constructors

 Discrete [(p, a)]

Instances

 Num p => Monad (Discrete p) Functor (Discrete p) Num p => Applicative (Discrete p) Foldable (Discrete p) Traversable (Discrete p) (Num p, Ord p, Distribution Uniform p) => Distribution (Discrete p) a (Eq p, Eq a) => Eq (Discrete p a) (Show p, Show a) => Show (Discrete p a)

mapDiscreteWeights :: (p -> q) -> Discrete p e -> Discrete q eSource

Like fmap, but for the weights of a discrete distribution.

normalizeDiscreteWeights :: Fractional p => Discrete p e -> Discrete p eSource

Adjust all the weights of a discrete distribution so that they sum to unity. If not possible, returns the original distribution unchanged.

collectDiscreteEvents :: (Ord e, Num p, Ord p) => Discrete p e -> Discrete p eSource

Simplify a discrete distribution by combining equivalent events (the new event will have a weight equal to the sum of all the originals).

collectDiscreteEventsBy :: (e -> e -> Ordering) -> ([p] -> p) -> ([e] -> e) -> Discrete p e -> Discrete p eSource

Simplify a discrete distribution by combining equivalent events (the new event will have a weight equal to the sum of all the originals). The comparator function is used to identify events to combine. Once chosen, the events and their weights are combined (independently) by the provided weight and event aggregation functions.