Portability | portable |
---|---|
Stability | experimental |
Maintainer | bos@serpentine.com |
Types classes for probability distrubutions
- class Distribution d where
- cumulative :: d -> Double -> Double
- class Distribution d => DiscreteDistr d where
- probability :: d -> Int -> Double
- class Distribution d => ContDistr d where
- class Distribution d => Mean d where
- class Mean d => Variance d where
- findRoot :: ContDistr d => d -> Double -> Double -> Double -> Double -> Double
- sumProbabilities :: DiscreteDistr d => d -> Int -> Int -> Double
Type classes
class Distribution d whereSource
Type class common to all distributions. Only c.d.f. could be defined for both discrete and continous distributions.
cumulative :: d -> Double -> DoubleSource
Cumulative distribution function. The probability that a random variable X is less or equal than x, i.e. P(X≤x).
class Distribution d => DiscreteDistr d whereSource
Discrete probability distribution.
probability :: d -> Int -> DoubleSource
Probability of n-th outcome.
class Distribution d => ContDistr d whereSource
Continuous probability distributuion
class Distribution d => Mean d whereSource
Type class for distributions with mean.
Helper functions
:: ContDistr d | |
=> d | Distribution |
-> Double | Probability p |
-> Double | Initial guess |
-> Double | Lower bound on interval |
-> Double | Upper bound on interval |
-> Double |
Approximate the value of X for which P(x>X)=p.
This method uses a combination of Newton-Raphson iteration and bisection with the given guess as a starting point. The upper and lower bounds specify the interval in which the probability distribution reaches the value p.
sumProbabilities :: DiscreteDistr d => d -> Int -> Int -> DoubleSource
Sum probabilities in inclusive interval.