Copyright | Predictable Network Solutions Ltd. 2020-2024 |
---|---|
License | BSD-3-Clause |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- data Prob a
- dirac :: (Ord a, Num a) => a -> Prob a
- uniform :: (Ord a, Num a, Fractional a) => a -> a -> Prob a
- distribution :: (Ord a, Num a) => Prob a -> Piecewise (Poly a)
- fromDistribution :: (Ord a, Num a, Fractional a) => Piecewise (Poly a) -> Maybe (Prob a)
- measure :: (Ord a, Num a) => Prob a -> Measure a
- fromMeasure :: (Ord a, Num a, Fractional a) => Measure a -> Maybe (Prob a)
- unsafeFromMeasure :: Measure a -> Prob a
- support :: (Ord a, Num a) => Prob a -> Maybe (a, a)
- expectation :: (Ord a, Num a, Fractional a) => Poly a -> Prob a -> a
- moments :: (Ord a, Num a, Fractional a) => Prob a -> Moments a
- choice :: (Ord a, Num a, Fractional a) => a -> Prob a -> Prob a -> Prob a
- translate :: (Ord a, Num a, Fractional a) => a -> Prob a -> Prob a
- convolve :: (Ord a, Num a, Fractional a) => Prob a -> Prob a -> Prob a
Type
A probability measure on the number line.
Instances
Show a => Show (Prob a) Source # | |
NFData a => NFData (Prob a) Source # | |
Defined in Numeric.Measure.Probability | |
(Ord a, Num a) => Eq (Prob a) Source # | Two probability measures are equal if they have the same cumulative distribution functions. px == py implies forall t. eval (distribution px) t = eval (distribution py) t |
dirac :: (Ord a, Num a) => a -> Prob a Source #
A
Dirac measure
at the given point x
.
dirac x
is the probability distribution where x
occurs with certainty.
uniform :: (Ord a, Num a, Fractional a) => a -> a -> Prob a Source #
The uniform probability distribution on the interval \( [x,y) \).
distribution :: (Ord a, Num a) => Prob a -> Piecewise (Poly a) Source #
eval (distribution m) x
is the probability of picking a number <= x
.
This is known as the cumulative distribution function.
fromDistribution :: (Ord a, Num a, Fractional a) => Piecewise (Poly a) -> Maybe (Prob a) Source #
Construct a probability distribution from its cumulative distribution function.
Return Nothing
if
* the cumulative distribution function is not monotonicall increasing
* the last piece of the piecewise function is not a constant
equal to 1
.
fromMeasure :: (Ord a, Num a, Fractional a) => Measure a -> Maybe (Prob a) Source #
unsafeFromMeasure :: Measure a -> Prob a Source #
View a Measure
as a probability distribution.
Variant of fromMeasure
where the precondition are not checked!
Observations
expectation :: (Ord a, Num a, Fractional a) => Poly a -> Prob a -> a Source #
Compute the
expected value
of a polynomial f
with respect to the given probability distribution,
\( E[f(X)] \).
moments :: (Ord a, Num a, Fractional a) => Prob a -> Moments a Source #
Compute the first four commonly used moments of a probability distribution.
Operations, numerical
choice :: (Ord a, Num a, Fractional a) => a -> Prob a -> Prob a -> Prob a Source #
Left-biased random choice.
choice p
is a probability distribution where
events from the left argument are chosen with probablity p
and events from the right argument are chosen with probability (1-p)
.
eval (distribution (choice p mx my)) z = p * eval (distribution mx) z + (1-p) * eval (distribution my) z