Data.Random.Distribution.Discrete
Synopsis
 discrete :: Distribution (Discrete p) a => [(p, a)] -> RVar a empirical :: (Num p, Ord a) => [a] -> Discrete p a newtype Discrete p a = Discrete [(p, a)] mapDiscreteWeights :: (p -> q) -> Discrete p e -> Discrete q e normalizeDiscreteWeights :: Fractional p => Discrete p e -> Discrete p e collectDiscreteEvents :: (Ord e, Num p, Ord p) => Discrete p e -> Discrete p e collectDiscreteEventsBy :: (e -> e -> Ordering) -> ([p] -> p) -> ([e] -> e) -> Discrete p e -> Discrete p e
Documentation
 discrete :: Distribution (Discrete p) a => [(p, a)] -> RVar a Source
 empirical :: (Num p, Ord a) => [a] -> Discrete p a Source
 newtype Discrete p a Source
Constructors
 Discrete [(p, a)]
Instances
 Num p => Monad (Discrete p) Functor (Discrete p) Traversable (Discrete p) Foldable (Discrete p) Num p => Applicative (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 e Source
Like fmap, but for the weights of a discrete distribution.
 normalizeDiscreteWeights :: Fractional p => Discrete p e -> Discrete p e Source
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 e Source
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 e Source
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.