statistics-0.13.3.0: A library of statistical types, data, and functions

Copyright | (c) 2009 Bryan O'Sullivan
License | BSD3
Maintainer | bos@serpentine.com
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell98

Statistics.Distribution

Contents

- Type classes
  - Distribution statistics
  - Random number generation
- Helper functions

Description

Type classes for probability distributions

Synopsis

- class Distribution d where
- class Distribution d => DiscreteDistr d where
- class Distribution d => ContDistr d where
- class Distribution d => MaybeMean d where
- class MaybeMean d => Mean d where
- class MaybeMean d => MaybeVariance d where
- class (Mean d, MaybeVariance d) => Variance d where
- class Distribution d => MaybeEntropy d where
- class MaybeEntropy d => Entropy d where
- class Distribution d => ContGen d where
- class (DiscreteDistr d, ContGen d) => DiscreteGen d where
- genContinous :: (ContDistr d, PrimMonad m) => d -> Gen (PrimState m) -> m Double
- findRoot :: ContDistr d => d -> Double -> Double -> Double -> Double -> Double
- sumProbabilities :: DiscreteDistr d => d -> Int -> Int -> Double

# Type classes

class Distribution d where Source #

Type class common to all distributions. Only c.d.f. could be defined for both discrete and continous distributions.

Minimal complete definition

cumulative

Methods

cumulative :: d -> Double -> Double Source #

Cumulative distribution function. The probability that a random variable X is less or equal than x, i.e. P(X≤x). Cumulative should be defined for infinities as well:

    cumulative d +∞ = 1
    cumulative d -∞ = 0

complCumulative :: d -> Double -> Double Source #

One's complement of cumulative distibution:

    complCumulative d x = 1 - cumulative d x

It's useful when one is interested in P(X>x) and expression on the right side begin to lose precision. This function have default implementation but implementors are encouraged to provide more precise implementation.

Instances

Distribution BetaDistribution Source # |
Methods cumulative :: BetaDistribution -> Double -> Double Source # complCumulative :: BetaDistribution -> Double -> Double Source #
Distribution BinomialDistribution Source # |
Methods cumulative :: BinomialDistribution -> Double -> Double Source # complCumulative :: BinomialDistribution -> Double -> Double Source #
Distribution CauchyDistribution Source # |
Methods cumulative :: CauchyDistribution -> Double -> Double Source # complCumulative :: CauchyDistribution -> Double -> Double Source #
Distribution ChiSquared Source # |
Methods cumulative :: ChiSquared -> Double -> Double Source # complCumulative :: ChiSquared -> Double -> Double Source #
Distribution ExponentialDistribution Source # |
Methods cumulative :: ExponentialDistribution -> Double -> Double Source # complCumulative :: ExponentialDistribution -> Double -> Double Source #
Distribution FDistribution Source # |
Methods cumulative :: FDistribution -> Double -> Double Source # complCumulative :: FDistribution -> Double -> Double Source #
Distribution GammaDistribution Source # |
Methods cumulative :: GammaDistribution -> Double -> Double Source # complCumulative :: GammaDistribution -> Double -> Double Source #
Distribution GeometricDistribution0 Source # |
Methods cumulative :: GeometricDistribution0 -> Double -> Double Source # complCumulative :: GeometricDistribution0 -> Double -> Double Source #
Distribution GeometricDistribution Source # |
Methods cumulative :: GeometricDistribution -> Double -> Double Source # complCumulative :: GeometricDistribution -> Double -> Double Source #
Distribution HypergeometricDistribution Source # |
Methods cumulative :: HypergeometricDistribution -> Double -> Double Source # complCumulative :: HypergeometricDistribution -> Double -> Double Source #
Distribution LaplaceDistribution Source # |
Methods cumulative :: LaplaceDistribution -> Double -> Double Source # complCumulative :: LaplaceDistribution -> Double -> Double Source #
Distribution NormalDistribution Source # |
Methods cumulative :: NormalDistribution -> Double -> Double Source # complCumulative :: NormalDistribution -> Double -> Double Source #
Distribution PoissonDistribution Source # |
Methods cumulative :: PoissonDistribution -> Double -> Double Source # complCumulative :: PoissonDistribution -> Double -> Double Source #
Distribution StudentT Source # |
Methods cumulative :: StudentT -> Double -> Double Source # complCumulative :: StudentT -> Double -> Double Source #
Distribution UniformDistribution Source # |
Methods cumulative :: UniformDistribution -> Double -> Double Source # complCumulative :: UniformDistribution -> Double -> Double Source #
Distribution d => Distribution (LinearTransform d) Source # |
Methods cumulative :: LinearTransform d -> Double -> Double Source # complCumulative :: LinearTransform d -> Double -> Double Source #

class Distribution d => DiscreteDistr d where Source #

Discrete probability distribution.

Methods

probability :: d -> Int -> Double Source #

Probability of n-th outcome.

logProbability :: d -> Int -> Double Source #

Logarithm of probability of n-th outcome

Instances

DiscreteDistr BinomialDistribution Source # |
Methods probability :: BinomialDistribution -> Int -> Double Source # logProbability :: BinomialDistribution -> Int -> Double Source #
DiscreteDistr GeometricDistribution0 Source # |
Methods probability :: GeometricDistribution0 -> Int -> Double Source # logProbability :: GeometricDistribution0 -> Int -> Double Source #
DiscreteDistr GeometricDistribution Source # |
Methods probability :: GeometricDistribution -> Int -> Double Source # logProbability :: GeometricDistribution -> Int -> Double Source #
DiscreteDistr HypergeometricDistribution Source # |
Methods probability :: HypergeometricDistribution -> Int -> Double Source # logProbability :: HypergeometricDistribution -> Int -> Double Source #
DiscreteDistr PoissonDistribution Source # |
Methods probability :: PoissonDistribution -> Int -> Double Source # logProbability :: PoissonDistribution -> Int -> Double Source #

class Distribution d => ContDistr d where Source #

Continuous probability distributuion.

Minimal complete definition is `quantile` and either `density` or `logDensity`.

Minimal complete definition

quantile

Methods

density :: d -> Double -> Double Source #

Probability density function. Probability that random variable X lies in the infinitesimal interval [x,x+δx) equal to density(x)⋅δx

quantile :: d -> Double -> Double Source #

Inverse of the cumulative distribution function. The value x for which P(X≤x) = p. If probability is outside of [0,1] range function should call `error`

logDensity :: d -> Double -> Double Source #

Natural logarithm of density.

Instances

ContDistr BetaDistribution Source # |
Methods density :: BetaDistribution -> Double -> Double Source # quantile :: BetaDistribution -> Double -> Double Source # logDensity :: BetaDistribution -> Double -> Double Source #
ContDistr CauchyDistribution Source # |
Methods density :: CauchyDistribution -> Double -> Double Source # quantile :: CauchyDistribution -> Double -> Double Source # logDensity :: CauchyDistribution -> Double -> Double Source #
ContDistr ChiSquared Source # |
Methods density :: ChiSquared -> Double -> Double Source # quantile :: ChiSquared -> Double -> Double Source # logDensity :: ChiSquared -> Double -> Double Source #
ContDistr ExponentialDistribution Source # |
Methods density :: ExponentialDistribution -> Double -> Double Source # quantile :: ExponentialDistribution -> Double -> Double Source # logDensity :: ExponentialDistribution -> Double -> Double Source #
ContDistr FDistribution Source # |
Methods density :: FDistribution -> Double -> Double Source # quantile :: FDistribution -> Double -> Double Source # logDensity :: FDistribution -> Double -> Double Source #
ContDistr GammaDistribution Source # |
Methods density :: GammaDistribution -> Double -> Double Source # quantile :: GammaDistribution -> Double -> Double Source # logDensity :: GammaDistribution -> Double -> Double Source #
ContDistr LaplaceDistribution Source # |
Methods density :: LaplaceDistribution -> Double -> Double Source # quantile :: LaplaceDistribution -> Double -> Double Source # logDensity :: LaplaceDistribution -> Double -> Double Source #
ContDistr NormalDistribution Source # |
Methods density :: NormalDistribution -> Double -> Double Source # quantile :: NormalDistribution -> Double -> Double Source # logDensity :: NormalDistribution -> Double -> Double Source #
ContDistr StudentT Source # |
Methods density :: StudentT -> Double -> Double Source # quantile :: StudentT -> Double -> Double Source # logDensity :: StudentT -> Double -> Double Source #
ContDistr UniformDistribution Source # |
Methods density :: UniformDistribution -> Double -> Double Source # quantile :: UniformDistribution -> Double -> Double Source # logDensity :: UniformDistribution -> Double -> Double Source #
ContDistr d => ContDistr (LinearTransform d) Source # |
Methods density :: LinearTransform d -> Double -> Double Source # quantile :: LinearTransform d -> Double -> Double Source # logDensity :: LinearTransform d -> Double -> Double Source #

## Distribution statistics

class Distribution d => MaybeMean d where Source #

Type class for distributions with mean. `maybeMean` should return `Nothing` if it's undefined for current value of data

Minimal complete definition

maybeMean

Methods

maybeMean :: d -> Maybe Double Source #

Instances

MaybeMean BetaDistribution Source # |
Methods maybeMean :: BetaDistribution -> Maybe Double Source #
MaybeMean BinomialDistribution Source # |
Methods maybeMean :: BinomialDistribution -> Maybe Double Source #
MaybeMean ChiSquared Source # |
Methods maybeMean :: ChiSquared -> Maybe Double Source #
MaybeMean ExponentialDistribution Source # |
Methods maybeMean :: ExponentialDistribution -> Maybe Double Source #
MaybeMean FDistribution Source # |
Methods maybeMean :: FDistribution -> Maybe Double Source #
MaybeMean GammaDistribution Source # |
Methods maybeMean :: GammaDistribution -> Maybe Double Source #
MaybeMean GeometricDistribution0 Source # |
Methods maybeMean :: GeometricDistribution0 -> Maybe Double Source #
MaybeMean GeometricDistribution Source # |
Methods maybeMean :: GeometricDistribution -> Maybe Double Source #
MaybeMean HypergeometricDistribution Source # |
Methods maybeMean :: HypergeometricDistribution -> Maybe Double Source #
MaybeMean LaplaceDistribution Source # |
Methods maybeMean :: LaplaceDistribution -> Maybe Double Source #
MaybeMean NormalDistribution Source # |
Methods maybeMean :: NormalDistribution -> Maybe Double Source #
MaybeMean PoissonDistribution Source # |
Methods maybeMean :: PoissonDistribution -> Maybe Double Source #
MaybeMean StudentT Source # |
Methods maybeMean :: StudentT -> Maybe Double Source #
MaybeMean UniformDistribution Source # |
Methods maybeMean :: UniformDistribution -> Maybe Double Source #
MaybeMean d => MaybeMean (LinearTransform d) Source # |
Methods maybeMean :: LinearTransform d -> Maybe Double Source #

class MaybeMean d => Mean d where Source #

Type class for distributions with mean. If distribution have finite mean for all valid values of parameters it should be instance of this type class.

Minimal complete definition

mean

Methods

mean :: d -> Double Source #

Instances

Mean BetaDistribution Source # |
Methods mean :: BetaDistribution -> Double Source #
Mean BinomialDistribution Source # |
Methods mean :: BinomialDistribution -> Double Source #
Mean ChiSquared Source # |
Methods mean :: ChiSquared -> Double Source #
Mean ExponentialDistribution Source # |
Methods mean :: ExponentialDistribution -> Double Source #
Mean GammaDistribution Source # |
Methods mean :: GammaDistribution -> Double Source #
Mean GeometricDistribution0 Source # |
Methods mean :: GeometricDistribution0 -> Double Source #
Mean GeometricDistribution Source # |
Methods mean :: GeometricDistribution -> Double Source #
Mean HypergeometricDistribution Source # |
Methods mean :: HypergeometricDistribution -> Double Source #
Mean LaplaceDistribution Source # |
Methods mean :: LaplaceDistribution -> Double Source #
Mean NormalDistribution Source # |
Methods mean :: NormalDistribution -> Double Source #
Mean PoissonDistribution Source # |
Methods mean :: PoissonDistribution -> Double Source #
Mean UniformDistribution Source # |
Methods mean :: UniformDistribution -> Double Source #
Mean d => Mean (LinearTransform d) Source # |
Methods mean :: LinearTransform d -> Double Source #

class MaybeMean d => MaybeVariance d where Source #

Type class for distributions with variance. If variance is undefined for some parameter values both `maybeVariance` and `maybeStdDev` should return Nothing.

Minimal complete definition is `maybeVariance` or `maybeStdDev`

Methods

maybeVariance :: d -> Maybe Double Source #

maybeStdDev :: d -> Maybe Double Source #

Instances

MaybeVariance BetaDistribution Source # |
Methods maybeVariance :: BetaDistribution -> Maybe Double Source # maybeStdDev :: BetaDistribution -> Maybe Double Source #
MaybeVariance BinomialDistribution Source # |
Methods maybeVariance :: BinomialDistribution -> Maybe Double Source # maybeStdDev :: BinomialDistribution -> Maybe Double Source #
MaybeVariance ChiSquared Source # |
Methods maybeVariance :: ChiSquared -> Maybe Double Source # maybeStdDev :: ChiSquared -> Maybe Double Source #
MaybeVariance ExponentialDistribution Source # |
Methods maybeVariance :: ExponentialDistribution -> Maybe Double Source # maybeStdDev :: ExponentialDistribution -> Maybe Double Source #
MaybeVariance FDistribution Source # |
Methods maybeVariance :: FDistribution -> Maybe Double Source # maybeStdDev :: FDistribution -> Maybe Double Source #
MaybeVariance GammaDistribution Source # |
Methods maybeVariance :: GammaDistribution -> Maybe Double Source # maybeStdDev :: GammaDistribution -> Maybe Double Source #
MaybeVariance GeometricDistribution0 Source # |
Methods maybeVariance :: GeometricDistribution0 -> Maybe Double Source # maybeStdDev :: GeometricDistribution0 -> Maybe Double Source #
MaybeVariance GeometricDistribution Source # |
Methods maybeVariance :: GeometricDistribution -> Maybe Double Source # maybeStdDev :: GeometricDistribution -> Maybe Double Source #
MaybeVariance HypergeometricDistribution Source # |
Methods maybeVariance :: HypergeometricDistribution -> Maybe Double Source # maybeStdDev :: HypergeometricDistribution -> Maybe Double Source #
MaybeVariance LaplaceDistribution Source # |
Methods maybeVariance :: LaplaceDistribution -> Maybe Double Source # maybeStdDev :: LaplaceDistribution -> Maybe Double Source #
MaybeVariance NormalDistribution Source # |
Methods maybeVariance :: NormalDistribution -> Maybe Double Source # maybeStdDev :: NormalDistribution -> Maybe Double Source #
MaybeVariance PoissonDistribution Source # |
Methods maybeVariance :: PoissonDistribution -> Maybe Double Source # maybeStdDev :: PoissonDistribution -> Maybe Double Source #
MaybeVariance StudentT Source # |
Methods maybeVariance :: StudentT -> Maybe Double Source # maybeStdDev :: StudentT -> Maybe Double Source #
MaybeVariance UniformDistribution Source # |
Methods maybeVariance :: UniformDistribution -> Maybe Double Source # maybeStdDev :: UniformDistribution -> Maybe Double Source #
MaybeVariance d => MaybeVariance (LinearTransform d) Source # |
Methods maybeVariance :: LinearTransform d -> Maybe Double Source # maybeStdDev :: LinearTransform d -> Maybe Double Source #

class (Mean d, MaybeVariance d) => Variance d where Source #

Type class for distributions with variance. If distibution have finite variance for all valid parameter values it should be instance of this type class.

Minimal complete definition is `variance` or `stdDev`

Methods

variance :: d -> Double Source #

stdDev :: d -> Double Source #

Instances

Variance BetaDistribution Source # |
Methods variance :: BetaDistribution -> Double Source # stdDev :: BetaDistribution -> Double Source #
Variance BinomialDistribution Source # |
Methods variance :: BinomialDistribution -> Double Source # stdDev :: BinomialDistribution -> Double Source #
Variance ChiSquared Source # |
Methods variance :: ChiSquared -> Double Source # stdDev :: ChiSquared -> Double Source #
Variance ExponentialDistribution Source # |
Methods variance :: ExponentialDistribution -> Double Source # stdDev :: ExponentialDistribution -> Double Source #
Variance GammaDistribution Source # |
Methods variance :: GammaDistribution -> Double Source # stdDev :: GammaDistribution -> Double Source #
Variance GeometricDistribution0 Source # |
Methods variance :: GeometricDistribution0 -> Double Source # stdDev :: GeometricDistribution0 -> Double Source #
Variance GeometricDistribution Source # |
Methods variance :: GeometricDistribution -> Double Source # stdDev :: GeometricDistribution -> Double Source #
Variance HypergeometricDistribution Source # |
Methods variance :: HypergeometricDistribution -> Double Source # stdDev :: HypergeometricDistribution -> Double Source #
Variance LaplaceDistribution Source # |
Methods variance :: LaplaceDistribution -> Double Source # stdDev :: LaplaceDistribution -> Double Source #
Variance NormalDistribution Source # |
Methods variance :: NormalDistribution -> Double Source # stdDev :: NormalDistribution -> Double Source #
Variance PoissonDistribution Source # |
Methods variance :: PoissonDistribution -> Double Source # stdDev :: PoissonDistribution -> Double Source #
Variance UniformDistribution Source # |
Methods variance :: UniformDistribution -> Double Source # stdDev :: UniformDistribution -> Double Source #
Variance d => Variance (LinearTransform d) Source # |
Methods variance :: LinearTransform d -> Double Source # stdDev :: LinearTransform d -> Double Source #

class Distribution d => MaybeEntropy d where Source #

Type class for distributions with entropy, meaning Shannon entropy in the case of a discrete distribution, or differential entropy in the case of a continuous one. `maybeEntropy` should return `Nothing` if entropy is undefined for the chosen parameter values.

Minimal complete definition

maybeEntropy

Methods

maybeEntropy :: d -> Maybe Double Source #

Returns the entropy of a distribution, in nats, if such is defined.

Instances

MaybeEntropy BetaDistribution Source # |
Methods maybeEntropy :: BetaDistribution -> Maybe Double Source #
MaybeEntropy BinomialDistribution Source # |
Methods maybeEntropy :: BinomialDistribution -> Maybe Double Source #
MaybeEntropy CauchyDistribution Source # |
Methods maybeEntropy :: CauchyDistribution -> Maybe Double Source #
MaybeEntropy ChiSquared Source # |
Methods maybeEntropy :: ChiSquared -> Maybe Double Source #
MaybeEntropy ExponentialDistribution Source # |
Methods maybeEntropy :: ExponentialDistribution -> Maybe Double Source #
MaybeEntropy FDistribution Source # |
Methods maybeEntropy :: FDistribution -> Maybe Double Source #
MaybeEntropy GammaDistribution Source # |
Methods maybeEntropy :: GammaDistribution -> Maybe Double Source #
MaybeEntropy GeometricDistribution0 Source # |
Methods maybeEntropy :: GeometricDistribution0 -> Maybe Double Source #
MaybeEntropy GeometricDistribution Source # |
Methods maybeEntropy :: GeometricDistribution -> Maybe Double Source #
MaybeEntropy HypergeometricDistribution Source # |
Methods maybeEntropy :: HypergeometricDistribution -> Maybe Double Source #
MaybeEntropy LaplaceDistribution Source # |
Methods maybeEntropy :: LaplaceDistribution -> Maybe Double Source #
MaybeEntropy NormalDistribution Source # |
Methods maybeEntropy :: NormalDistribution -> Maybe Double Source #
MaybeEntropy PoissonDistribution Source # |
Methods maybeEntropy :: PoissonDistribution -> Maybe Double Source #
MaybeEntropy StudentT Source # |
Methods maybeEntropy :: StudentT -> Maybe Double Source #
MaybeEntropy UniformDistribution Source # |
Methods maybeEntropy :: UniformDistribution -> Maybe Double Source #
(MaybeEntropy d, DiscreteDistr d) => MaybeEntropy (LinearTransform d) Source # |
Methods maybeEntropy :: LinearTransform d -> Maybe Double Source #

class MaybeEntropy d => Entropy d where Source #

Type class for distributions with entropy, meaning Shannon entropy in the case of a discrete distribution, or differential entropy in the case of a continuous one. If the distribution has well-defined entropy for all valid parameter values then it should be an instance of this type class.

Minimal complete definition

entropy

Methods

entropy :: d -> Double Source #

Returns the entropy of a distribution, in nats.

Instances

Entropy BetaDistribution Source # |
Methods entropy :: BetaDistribution -> Double Source #
Entropy BinomialDistribution Source # |
Methods entropy :: BinomialDistribution -> Double Source #
Entropy CauchyDistribution Source # |
Methods entropy :: CauchyDistribution -> Double Source #
Entropy ChiSquared Source # |
Methods entropy :: ChiSquared -> Double Source #
Entropy ExponentialDistribution Source # |
Methods entropy :: ExponentialDistribution -> Double Source #
Entropy FDistribution Source # |
Methods entropy :: FDistribution -> Double Source #
Entropy GeometricDistribution0 Source # |
Methods entropy :: GeometricDistribution0 -> Double Source #
Entropy GeometricDistribution Source # |
Methods entropy :: GeometricDistribution -> Double Source #
Entropy HypergeometricDistribution Source # |
Methods entropy :: HypergeometricDistribution -> Double Source #
Entropy LaplaceDistribution Source # |
Methods entropy :: LaplaceDistribution -> Double Source #
Entropy NormalDistribution Source # |
Methods entropy :: NormalDistribution -> Double Source #
Entropy PoissonDistribution Source # |
Methods entropy :: PoissonDistribution -> Double Source #
Entropy StudentT Source # |
Methods entropy :: StudentT -> Double Source #
Entropy UniformDistribution Source # |
Methods entropy :: UniformDistribution -> Double Source #
(Entropy d, DiscreteDistr d) => Entropy (LinearTransform d) Source # |
Methods entropy :: LinearTransform d -> Double Source #

## Random number generation

class Distribution d => ContGen d where Source #

Generate discrete random variates which have given distribution.

Minimal complete definition

genContVar

Methods

genContVar :: PrimMonad m => d -> Gen (PrimState m) -> m Double Source #

Instances

ContGen BetaDistribution Source # |
Methods genContVar :: PrimMonad m => BetaDistribution -> Gen (PrimState m) -> m Double Source #
ContGen CauchyDistribution Source # |
Methods genContVar :: PrimMonad m => CauchyDistribution -> Gen (PrimState m) -> m Double Source #
ContGen ChiSquared Source # |
Methods genContVar :: PrimMonad m => ChiSquared -> Gen (PrimState m) -> m Double Source #
ContGen ExponentialDistribution Source # |
Methods genContVar :: PrimMonad m => ExponentialDistribution -> Gen (PrimState m) -> m Double Source #
ContGen FDistribution Source # |
Methods genContVar :: PrimMonad m => FDistribution -> Gen (PrimState m) -> m Double Source #
ContGen GammaDistribution Source # |
Methods genContVar :: PrimMonad m => GammaDistribution -> Gen (PrimState m) -> m Double Source #
ContGen GeometricDistribution0 Source # |
Methods genContVar :: PrimMonad m => GeometricDistribution0 -> Gen (PrimState m) -> m Double Source #
ContGen GeometricDistribution Source # |
Methods genContVar :: PrimMonad m => GeometricDistribution -> Gen (PrimState m) -> m Double Source #
ContGen LaplaceDistribution Source # |
Methods genContVar :: PrimMonad m => LaplaceDistribution -> Gen (PrimState m) -> m Double Source #
ContGen NormalDistribution Source # |
Methods genContVar :: PrimMonad m => NormalDistribution -> Gen (PrimState m) -> m Double Source #
ContGen StudentT Source # |
Methods genContVar :: PrimMonad m => StudentT -> Gen (PrimState m) -> m Double Source #
ContGen UniformDistribution Source # |
Methods genContVar :: PrimMonad m => UniformDistribution -> Gen (PrimState m) -> m Double Source #
ContGen d => ContGen (LinearTransform d) Source # |
Methods genContVar :: PrimMonad m => LinearTransform d -> Gen (PrimState m) -> m Double Source #

class (DiscreteDistr d, ContGen d) => DiscreteGen d where Source #

Generate discrete random variates which have given distribution. `ContGen` is superclass because it's always possible to generate real-valued variates from integer values

Minimal complete definition

genDiscreteVar

Methods

genDiscreteVar :: PrimMonad m => d -> Gen (PrimState m) -> m Int Source #

Instances

DiscreteGen GeometricDistribution0 Source # |
Methods genDiscreteVar :: PrimMonad m => GeometricDistribution0 -> Gen (PrimState m) -> m Int Source #
DiscreteGen GeometricDistribution Source # |
Methods genDiscreteVar :: PrimMonad m => GeometricDistribution -> Gen (PrimState m) -> m Int Source #

genContinous :: (ContDistr d, PrimMonad m) => d -> Gen (PrimState m) -> m Double Source #

Generate variates from continous distribution using inverse transform rule.

# Helper functions

findRoot Source #

Arguments

:: 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 -> Double Source #

Sum probabilities in inclusive interval.