statistics-0.16.1.2: 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 Haskell2010

Statistics.Distribution

Description

Type classes for probability distributions

Synopsis

Type classes

class Distribution d where Source #

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

Minimal complete definition

( cumulative | complCumulative )

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 distribution:

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

Instances details
Distribution UniformDistribution Source #
Instance details

Defined in Statistics.Distribution.Uniform

Distribution StudentT Source #
Instance details

Defined in Statistics.Distribution.StudentT

Distribution PoissonDistribution Source #
Instance details

Defined in Statistics.Distribution.Poisson

Distribution HypergeometricDistribution Source #
Instance details

Defined in Statistics.Distribution.Hypergeometric

Distribution GeometricDistribution0 Source #
Instance details

Defined in Statistics.Distribution.Geometric

Distribution GeometricDistribution Source #
Instance details

Defined in Statistics.Distribution.Geometric

Distribution GammaDistribution Source #
Instance details

Defined in Statistics.Distribution.Gamma

Distribution FDistribution Source #
Instance details

Defined in Statistics.Distribution.FDistribution

Distribution DiscreteUniform Source #
Instance details

Defined in Statistics.Distribution.DiscreteUniform

Distribution ChiSquared Source #
Instance details

Defined in Statistics.Distribution.ChiSquared

Distribution CauchyDistribution Source #
Instance details

Defined in Statistics.Distribution.CauchyLorentz

Distribution BinomialDistribution Source #
Instance details

Defined in Statistics.Distribution.Binomial

Distribution BetaDistribution Source #
Instance details

Defined in Statistics.Distribution.Beta

Distribution WeibullDistribution Source #
Instance details

Defined in Statistics.Distribution.Weibull

Distribution NormalDistribution Source #
Instance details

Defined in Statistics.Distribution.Normal

Distribution LognormalDistribution Source #
Instance details

Defined in Statistics.Distribution.Lognormal

Distribution LaplaceDistribution Source #
Instance details

Defined in Statistics.Distribution.Laplace

Distribution ExponentialDistribution Source #
Instance details

Defined in Statistics.Distribution.Exponential

Distribution d => Distribution ( LinearTransform d) Source #
Instance details

Defined in Statistics.Distribution.Transform

class Distribution d => DiscreteDistr d where Source #

Discrete probability distribution.

Minimal complete definition

( probability | logProbability )

Methods

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

Probability of n-th outcome.

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

Logarithm of probability of n-th outcome

class Distribution d => ContDistr d where Source #

Continuous probability distribution.

Minimal complete definition is quantile and either density or logDensity .

Minimal complete definition

( density | logDensity ), ( quantile | complQuantile )

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

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

Natural logarithm of density.

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

complQuantile :: d -> Double -> Double Source #

1-complement of quantile :

complQuantile x ≡ quantile (1 - x)

Instances

Instances details
ContDistr UniformDistribution Source #
Instance details

Defined in Statistics.Distribution.Uniform

ContDistr StudentT Source #
Instance details

Defined in Statistics.Distribution.StudentT

ContDistr GammaDistribution Source #
Instance details

Defined in Statistics.Distribution.Gamma

ContDistr FDistribution Source #
Instance details

Defined in Statistics.Distribution.FDistribution

ContDistr ChiSquared Source #
Instance details

Defined in Statistics.Distribution.ChiSquared

ContDistr CauchyDistribution Source #
Instance details

Defined in Statistics.Distribution.CauchyLorentz

ContDistr BetaDistribution Source #
Instance details

Defined in Statistics.Distribution.Beta

ContDistr WeibullDistribution Source #
Instance details

Defined in Statistics.Distribution.Weibull

ContDistr NormalDistribution Source #
Instance details

Defined in Statistics.Distribution.Normal

ContDistr LognormalDistribution Source #
Instance details

Defined in Statistics.Distribution.Lognormal

ContDistr LaplaceDistribution Source #
Instance details

Defined in Statistics.Distribution.Laplace

ContDistr ExponentialDistribution Source #
Instance details

Defined in Statistics.Distribution.Exponential

ContDistr d => ContDistr ( LinearTransform d) Source #
Instance details

Defined in Statistics.Distribution.Transform

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

Instances

Instances details
MaybeMean UniformDistribution Source #
Instance details

Defined in Statistics.Distribution.Uniform

MaybeMean StudentT Source #
Instance details

Defined in Statistics.Distribution.StudentT

MaybeMean PoissonDistribution Source #
Instance details

Defined in Statistics.Distribution.Poisson

MaybeMean HypergeometricDistribution Source #
Instance details

Defined in Statistics.Distribution.Hypergeometric

MaybeMean GeometricDistribution0 Source #
Instance details

Defined in Statistics.Distribution.Geometric

MaybeMean GeometricDistribution Source #
Instance details

Defined in Statistics.Distribution.Geometric

MaybeMean GammaDistribution Source #
Instance details

Defined in Statistics.Distribution.Gamma

MaybeMean FDistribution Source #
Instance details

Defined in Statistics.Distribution.FDistribution

MaybeMean DiscreteUniform Source #
Instance details

Defined in Statistics.Distribution.DiscreteUniform

MaybeMean ChiSquared Source #
Instance details

Defined in Statistics.Distribution.ChiSquared

MaybeMean BinomialDistribution Source #
Instance details

Defined in Statistics.Distribution.Binomial

MaybeMean BetaDistribution Source #
Instance details

Defined in Statistics.Distribution.Beta

MaybeMean WeibullDistribution Source #
Instance details

Defined in Statistics.Distribution.Weibull

MaybeMean NormalDistribution Source #
Instance details

Defined in Statistics.Distribution.Normal

MaybeMean LognormalDistribution Source #
Instance details

Defined in Statistics.Distribution.Lognormal

MaybeMean LaplaceDistribution Source #
Instance details

Defined in Statistics.Distribution.Laplace

MaybeMean ExponentialDistribution Source #
Instance details

Defined in Statistics.Distribution.Exponential

MaybeMean d => MaybeMean ( LinearTransform d) Source #
Instance details

Defined in Statistics.Distribution.Transform

class MaybeMean d => Mean d where Source #

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

Instances

Instances details
Mean UniformDistribution Source #
Instance details

Defined in Statistics.Distribution.Uniform

Mean PoissonDistribution Source #
Instance details

Defined in Statistics.Distribution.Poisson

Mean HypergeometricDistribution Source #
Instance details

Defined in Statistics.Distribution.Hypergeometric

Mean GeometricDistribution0 Source #
Instance details

Defined in Statistics.Distribution.Geometric

Mean GeometricDistribution Source #
Instance details

Defined in Statistics.Distribution.Geometric

Mean GammaDistribution Source #
Instance details

Defined in Statistics.Distribution.Gamma

Mean DiscreteUniform Source #
Instance details

Defined in Statistics.Distribution.DiscreteUniform

Mean ChiSquared Source #
Instance details

Defined in Statistics.Distribution.ChiSquared

Mean BinomialDistribution Source #
Instance details

Defined in Statistics.Distribution.Binomial

Mean BetaDistribution Source #
Instance details

Defined in Statistics.Distribution.Beta

Mean WeibullDistribution Source #
Instance details

Defined in Statistics.Distribution.Weibull

Mean NormalDistribution Source #
Instance details

Defined in Statistics.Distribution.Normal

Mean LognormalDistribution Source #
Instance details

Defined in Statistics.Distribution.Lognormal

Mean LaplaceDistribution Source #
Instance details

Defined in Statistics.Distribution.Laplace

Mean ExponentialDistribution Source #
Instance details

Defined in Statistics.Distribution.Exponential

Mean d => Mean ( LinearTransform d) Source #
Instance details

Defined in Statistics.Distribution.Transform

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

Minimal complete definition

( maybeVariance | maybeStdDev )

Instances

Instances details
MaybeVariance UniformDistribution Source #
Instance details

Defined in Statistics.Distribution.Uniform

MaybeVariance StudentT Source #
Instance details

Defined in Statistics.Distribution.StudentT

MaybeVariance PoissonDistribution Source #
Instance details

Defined in Statistics.Distribution.Poisson

MaybeVariance HypergeometricDistribution Source #
Instance details

Defined in Statistics.Distribution.Hypergeometric

MaybeVariance GeometricDistribution0 Source #
Instance details

Defined in Statistics.Distribution.Geometric

MaybeVariance GeometricDistribution Source #
Instance details

Defined in Statistics.Distribution.Geometric

MaybeVariance GammaDistribution Source #
Instance details

Defined in Statistics.Distribution.Gamma

MaybeVariance FDistribution Source #
Instance details

Defined in Statistics.Distribution.FDistribution

MaybeVariance DiscreteUniform Source #
Instance details

Defined in Statistics.Distribution.DiscreteUniform

MaybeVariance ChiSquared Source #
Instance details

Defined in Statistics.Distribution.ChiSquared

MaybeVariance BinomialDistribution Source #
Instance details

Defined in Statistics.Distribution.Binomial

MaybeVariance BetaDistribution Source #
Instance details

Defined in Statistics.Distribution.Beta

MaybeVariance WeibullDistribution Source #
Instance details

Defined in Statistics.Distribution.Weibull

MaybeVariance NormalDistribution Source #
Instance details

Defined in Statistics.Distribution.Normal

MaybeVariance LognormalDistribution Source #
Instance details

Defined in Statistics.Distribution.Lognormal

MaybeVariance LaplaceDistribution Source #
Instance details

Defined in Statistics.Distribution.Laplace

MaybeVariance ExponentialDistribution Source #
Instance details

Defined in Statistics.Distribution.Exponential

MaybeVariance d => MaybeVariance ( LinearTransform d) Source #
Instance details

Defined in Statistics.Distribution.Transform

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

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

Minimal complete definition is variance or stdDev

Minimal complete definition

( variance | stdDev )

Instances

Instances details
Variance UniformDistribution Source #
Instance details

Defined in Statistics.Distribution.Uniform

Variance PoissonDistribution Source #
Instance details

Defined in Statistics.Distribution.Poisson

Variance HypergeometricDistribution Source #
Instance details

Defined in Statistics.Distribution.Hypergeometric

Variance GeometricDistribution0 Source #
Instance details

Defined in Statistics.Distribution.Geometric

Variance GeometricDistribution Source #
Instance details

Defined in Statistics.Distribution.Geometric

Variance GammaDistribution Source #
Instance details

Defined in Statistics.Distribution.Gamma

Variance DiscreteUniform Source #
Instance details

Defined in Statistics.Distribution.DiscreteUniform

Variance ChiSquared Source #
Instance details

Defined in Statistics.Distribution.ChiSquared

Variance BinomialDistribution Source #
Instance details

Defined in Statistics.Distribution.Binomial

Variance BetaDistribution Source #
Instance details

Defined in Statistics.Distribution.Beta

Variance WeibullDistribution Source #
Instance details

Defined in Statistics.Distribution.Weibull

Variance NormalDistribution Source #
Instance details

Defined in Statistics.Distribution.Normal

Variance LognormalDistribution Source #
Instance details

Defined in Statistics.Distribution.Lognormal

Variance LaplaceDistribution Source #
Instance details

Defined in Statistics.Distribution.Laplace

Variance ExponentialDistribution Source #
Instance details

Defined in Statistics.Distribution.Exponential

Variance d => Variance ( LinearTransform d) Source #
Instance details

Defined in Statistics.Distribution.Transform

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.

Methods

maybeEntropy :: d -> Maybe Double Source #

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

Instances

Instances details
MaybeEntropy UniformDistribution Source #
Instance details

Defined in Statistics.Distribution.Uniform

MaybeEntropy StudentT Source #
Instance details

Defined in Statistics.Distribution.StudentT

MaybeEntropy PoissonDistribution Source #
Instance details

Defined in Statistics.Distribution.Poisson

MaybeEntropy HypergeometricDistribution Source #
Instance details

Defined in Statistics.Distribution.Hypergeometric

MaybeEntropy GeometricDistribution0 Source #
Instance details

Defined in Statistics.Distribution.Geometric

MaybeEntropy GeometricDistribution Source #
Instance details

Defined in Statistics.Distribution.Geometric

MaybeEntropy GammaDistribution Source #
Instance details

Defined in Statistics.Distribution.Gamma

MaybeEntropy FDistribution Source #
Instance details

Defined in Statistics.Distribution.FDistribution

MaybeEntropy DiscreteUniform Source #
Instance details

Defined in Statistics.Distribution.DiscreteUniform

MaybeEntropy ChiSquared Source #
Instance details

Defined in Statistics.Distribution.ChiSquared

MaybeEntropy CauchyDistribution Source #
Instance details

Defined in Statistics.Distribution.CauchyLorentz

MaybeEntropy BinomialDistribution Source #
Instance details

Defined in Statistics.Distribution.Binomial

MaybeEntropy BetaDistribution Source #
Instance details

Defined in Statistics.Distribution.Beta

MaybeEntropy WeibullDistribution Source #
Instance details

Defined in Statistics.Distribution.Weibull

MaybeEntropy NormalDistribution Source #
Instance details

Defined in Statistics.Distribution.Normal

MaybeEntropy LognormalDistribution Source #
Instance details

Defined in Statistics.Distribution.Lognormal

MaybeEntropy LaplaceDistribution Source #
Instance details

Defined in Statistics.Distribution.Laplace

MaybeEntropy ExponentialDistribution Source #
Instance details

Defined in Statistics.Distribution.Exponential

MaybeEntropy d => MaybeEntropy ( LinearTransform d) Source #
Instance details

Defined in Statistics.Distribution.Transform

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.

Methods

entropy :: d -> Double Source #

Returns the entropy of a distribution, in nats.

Instances

Instances details
Entropy UniformDistribution Source #
Instance details

Defined in Statistics.Distribution.Uniform

Entropy StudentT Source #
Instance details

Defined in Statistics.Distribution.StudentT

Entropy PoissonDistribution Source #
Instance details

Defined in Statistics.Distribution.Poisson

Entropy HypergeometricDistribution Source #
Instance details

Defined in Statistics.Distribution.Hypergeometric

Entropy GeometricDistribution0 Source #
Instance details

Defined in Statistics.Distribution.Geometric

Entropy GeometricDistribution Source #
Instance details

Defined in Statistics.Distribution.Geometric

Entropy FDistribution Source #
Instance details

Defined in Statistics.Distribution.FDistribution

Entropy DiscreteUniform Source #
Instance details

Defined in Statistics.Distribution.DiscreteUniform

Entropy ChiSquared Source #
Instance details

Defined in Statistics.Distribution.ChiSquared

Entropy CauchyDistribution Source #
Instance details

Defined in Statistics.Distribution.CauchyLorentz

Entropy BinomialDistribution Source #
Instance details

Defined in Statistics.Distribution.Binomial

Entropy BetaDistribution Source #
Instance details

Defined in Statistics.Distribution.Beta

Entropy WeibullDistribution Source #
Instance details

Defined in Statistics.Distribution.Weibull

Entropy NormalDistribution Source #
Instance details

Defined in Statistics.Distribution.Normal

Entropy LognormalDistribution Source #
Instance details

Defined in Statistics.Distribution.Lognormal

Entropy LaplaceDistribution Source #
Instance details

Defined in Statistics.Distribution.Laplace

Entropy ExponentialDistribution Source #
Instance details

Defined in Statistics.Distribution.Exponential

Entropy d => Entropy ( LinearTransform d) Source #
Instance details

Defined in Statistics.Distribution.Transform

class FromSample d a where Source #

Estimate distribution from sample. First parameter in sample is distribution type and second is element type.

Methods

fromSample :: Vector v a => v a -> Maybe d Source #

Estimate distribution from sample. Returns nothing is there's not enough data to estimate or sample clearly doesn't come from distribution in question. For example if there's negative samples in exponential distribution.

Instances

Instances details
FromSample WeibullDistribution Double Source #

Uses an approximation based on the mean and standard deviation in weibullDistrEstMeanStddevErr , with standard deviation estimated using maximum likelihood method (unbiased estimation).

Returns Nothing if sample contains less than one element or variance is zero (all elements are equal), or if the estimated mean and standard-deviation lies outside the range for which the approximation is accurate.

Instance details

Defined in Statistics.Distribution.Weibull

FromSample NormalDistribution Double Source #

Variance is estimated using maximum likelihood method (biased estimation).

Returns Nothing if sample contains less than one element or variance is zero (all elements are equal)

Instance details

Defined in Statistics.Distribution.Normal

FromSample LognormalDistribution Double Source #

Variance is estimated using maximum likelihood method (biased estimation) over the log of the data.

Returns Nothing if sample contains less than one element or variance is zero (all elements are equal)

Instance details

Defined in Statistics.Distribution.Lognormal

FromSample LaplaceDistribution Double Source #

Create Laplace distribution from sample. No tests are made to check whether it truly is Laplace. Location of distribution estimated as median of sample.

Instance details

Defined in Statistics.Distribution.Laplace

FromSample ExponentialDistribution Double Source #

Create exponential distribution from sample. Returns Nothing if sample is empty or contains negative elements. No other tests are made to check whether it truly is exponential.

Instance details

Defined in Statistics.Distribution.Exponential

Random number generation

class Distribution d => ContGen d where Source #

Generate discrete random variates which have given distribution.

Instances

Instances details
ContGen UniformDistribution Source #
Instance details

Defined in Statistics.Distribution.Uniform

ContGen StudentT Source #
Instance details

Defined in Statistics.Distribution.StudentT

ContGen GeometricDistribution0 Source #
Instance details

Defined in Statistics.Distribution.Geometric

ContGen GeometricDistribution Source #
Instance details

Defined in Statistics.Distribution.Geometric

ContGen GammaDistribution Source #
Instance details

Defined in Statistics.Distribution.Gamma

ContGen FDistribution Source #
Instance details

Defined in Statistics.Distribution.FDistribution

ContGen DiscreteUniform Source #
Instance details

Defined in Statistics.Distribution.DiscreteUniform

ContGen ChiSquared Source #
Instance details

Defined in Statistics.Distribution.ChiSquared

ContGen CauchyDistribution Source #
Instance details

Defined in Statistics.Distribution.CauchyLorentz

ContGen BetaDistribution Source #
Instance details

Defined in Statistics.Distribution.Beta

ContGen WeibullDistribution Source #
Instance details

Defined in Statistics.Distribution.Weibull

ContGen NormalDistribution Source #
Instance details

Defined in Statistics.Distribution.Normal

ContGen LognormalDistribution Source #
Instance details

Defined in Statistics.Distribution.Lognormal

ContGen LaplaceDistribution Source #
Instance details

Defined in Statistics.Distribution.Laplace

ContGen ExponentialDistribution Source #
Instance details

Defined in Statistics.Distribution.Exponential

ContGen d => ContGen ( LinearTransform d) Source #
Instance details

Defined in Statistics.Distribution.Transform

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

genContinuous :: ( ContDistr d, StatefulGen g m) => d -> g -> m Double Source #

Generate variates from continuous 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.