statistics-0.16.2.0: A library of statistical types, data, and functions
Copyright(c) 2009 Bryan O'Sullivan
LicenseBSD3
Maintainerbos@serpentine.com
Stabilityexperimental
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

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(Xx). 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 BetaDistribution Source # 
Instance details

Defined in Statistics.Distribution.Beta

Distribution BinomialDistribution Source # 
Instance details

Defined in Statistics.Distribution.Binomial

Distribution CauchyDistribution Source # 
Instance details

Defined in Statistics.Distribution.CauchyLorentz

Distribution ChiSquared Source # 
Instance details

Defined in Statistics.Distribution.ChiSquared

Distribution DiscreteUniform Source # 
Instance details

Defined in Statistics.Distribution.DiscreteUniform

Distribution ExponentialDistribution Source # 
Instance details

Defined in Statistics.Distribution.Exponential

Distribution FDistribution Source # 
Instance details

Defined in Statistics.Distribution.FDistribution

Distribution GammaDistribution Source # 
Instance details

Defined in Statistics.Distribution.Gamma

Distribution GeometricDistribution Source # 
Instance details

Defined in Statistics.Distribution.Geometric

Distribution GeometricDistribution0 Source # 
Instance details

Defined in Statistics.Distribution.Geometric

Distribution HypergeometricDistribution Source # 
Instance details

Defined in Statistics.Distribution.Hypergeometric

Distribution LaplaceDistribution Source # 
Instance details

Defined in Statistics.Distribution.Laplace

Distribution LognormalDistribution Source # 
Instance details

Defined in Statistics.Distribution.Lognormal

Distribution NegativeBinomialDistribution Source # 
Instance details

Defined in Statistics.Distribution.NegativeBinomial

Distribution NormalDistribution Source # 
Instance details

Defined in Statistics.Distribution.Normal

Distribution PoissonDistribution Source # 
Instance details

Defined in Statistics.Distribution.Poisson

Distribution StudentT Source # 
Instance details

Defined in Statistics.Distribution.StudentT

Distribution UniformDistribution Source # 
Instance details

Defined in Statistics.Distribution.Uniform

Distribution WeibullDistribution Source # 
Instance details

Defined in Statistics.Distribution.Weibull

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

Instances

Instances details
DiscreteDistr BinomialDistribution Source # 
Instance details

Defined in Statistics.Distribution.Binomial

DiscreteDistr DiscreteUniform Source # 
Instance details

Defined in Statistics.Distribution.DiscreteUniform

DiscreteDistr GeometricDistribution Source # 
Instance details

Defined in Statistics.Distribution.Geometric

DiscreteDistr GeometricDistribution0 Source # 
Instance details

Defined in Statistics.Distribution.Geometric

DiscreteDistr HypergeometricDistribution Source # 
Instance details

Defined in Statistics.Distribution.Hypergeometric

DiscreteDistr NegativeBinomialDistribution Source # 
Instance details

Defined in Statistics.Distribution.NegativeBinomial

DiscreteDistr PoissonDistribution Source # 
Instance details

Defined in Statistics.Distribution.Poisson

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(Xx) = 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 BetaDistribution Source # 
Instance details

Defined in Statistics.Distribution.Beta

ContDistr CauchyDistribution Source # 
Instance details

Defined in Statistics.Distribution.CauchyLorentz

ContDistr ChiSquared Source # 
Instance details

Defined in Statistics.Distribution.ChiSquared

ContDistr ExponentialDistribution Source # 
Instance details

Defined in Statistics.Distribution.Exponential

ContDistr FDistribution Source # 
Instance details

Defined in Statistics.Distribution.FDistribution

ContDistr GammaDistribution Source # 
Instance details

Defined in Statistics.Distribution.Gamma

ContDistr LaplaceDistribution Source # 
Instance details

Defined in Statistics.Distribution.Laplace

ContDistr LognormalDistribution Source # 
Instance details

Defined in Statistics.Distribution.Lognormal

ContDistr NormalDistribution Source # 
Instance details

Defined in Statistics.Distribution.Normal

ContDistr StudentT Source # 
Instance details

Defined in Statistics.Distribution.StudentT

ContDistr UniformDistribution Source # 
Instance details

Defined in Statistics.Distribution.Uniform

ContDistr WeibullDistribution Source # 
Instance details

Defined in Statistics.Distribution.Weibull

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

Methods

maybeMean :: d -> Maybe Double Source #

Instances

Instances details
MaybeMean BetaDistribution Source # 
Instance details

Defined in Statistics.Distribution.Beta

MaybeMean BinomialDistribution Source # 
Instance details

Defined in Statistics.Distribution.Binomial

MaybeMean ChiSquared Source # 
Instance details

Defined in Statistics.Distribution.ChiSquared

MaybeMean DiscreteUniform Source # 
Instance details

Defined in Statistics.Distribution.DiscreteUniform

MaybeMean ExponentialDistribution Source # 
Instance details

Defined in Statistics.Distribution.Exponential

MaybeMean FDistribution Source # 
Instance details

Defined in Statistics.Distribution.FDistribution

MaybeMean GammaDistribution Source # 
Instance details

Defined in Statistics.Distribution.Gamma

MaybeMean GeometricDistribution Source # 
Instance details

Defined in Statistics.Distribution.Geometric

MaybeMean GeometricDistribution0 Source # 
Instance details

Defined in Statistics.Distribution.Geometric

MaybeMean HypergeometricDistribution Source # 
Instance details

Defined in Statistics.Distribution.Hypergeometric

MaybeMean LaplaceDistribution Source # 
Instance details

Defined in Statistics.Distribution.Laplace

MaybeMean LognormalDistribution Source # 
Instance details

Defined in Statistics.Distribution.Lognormal

MaybeMean NegativeBinomialDistribution Source # 
Instance details

Defined in Statistics.Distribution.NegativeBinomial

MaybeMean NormalDistribution Source # 
Instance details

Defined in Statistics.Distribution.Normal

MaybeMean PoissonDistribution Source # 
Instance details

Defined in Statistics.Distribution.Poisson

MaybeMean StudentT Source # 
Instance details

Defined in Statistics.Distribution.StudentT

MaybeMean UniformDistribution Source # 
Instance details

Defined in Statistics.Distribution.Uniform

MaybeMean WeibullDistribution Source # 
Instance details

Defined in Statistics.Distribution.Weibull

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.

Methods

mean :: d -> Double Source #

Instances

Instances details
Mean BetaDistribution Source # 
Instance details

Defined in Statistics.Distribution.Beta

Mean BinomialDistribution Source # 
Instance details

Defined in Statistics.Distribution.Binomial

Mean ChiSquared Source # 
Instance details

Defined in Statistics.Distribution.ChiSquared

Mean DiscreteUniform Source # 
Instance details

Defined in Statistics.Distribution.DiscreteUniform

Mean ExponentialDistribution Source # 
Instance details

Defined in Statistics.Distribution.Exponential

Mean GammaDistribution Source # 
Instance details

Defined in Statistics.Distribution.Gamma

Mean GeometricDistribution Source # 
Instance details

Defined in Statistics.Distribution.Geometric

Mean GeometricDistribution0 Source # 
Instance details

Defined in Statistics.Distribution.Geometric

Mean HypergeometricDistribution Source # 
Instance details

Defined in Statistics.Distribution.Hypergeometric

Mean LaplaceDistribution Source # 
Instance details

Defined in Statistics.Distribution.Laplace

Mean LognormalDistribution Source # 
Instance details

Defined in Statistics.Distribution.Lognormal

Mean NegativeBinomialDistribution Source # 
Instance details

Defined in Statistics.Distribution.NegativeBinomial

Mean NormalDistribution Source # 
Instance details

Defined in Statistics.Distribution.Normal

Mean PoissonDistribution Source # 
Instance details

Defined in Statistics.Distribution.Poisson

Mean UniformDistribution Source # 
Instance details

Defined in Statistics.Distribution.Uniform

Mean WeibullDistribution Source # 
Instance details

Defined in Statistics.Distribution.Weibull

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 BetaDistribution Source # 
Instance details

Defined in Statistics.Distribution.Beta

MaybeVariance BinomialDistribution Source # 
Instance details

Defined in Statistics.Distribution.Binomial

MaybeVariance ChiSquared Source # 
Instance details

Defined in Statistics.Distribution.ChiSquared

MaybeVariance DiscreteUniform Source # 
Instance details

Defined in Statistics.Distribution.DiscreteUniform

MaybeVariance ExponentialDistribution Source # 
Instance details

Defined in Statistics.Distribution.Exponential

MaybeVariance FDistribution Source # 
Instance details

Defined in Statistics.Distribution.FDistribution

MaybeVariance GammaDistribution Source # 
Instance details

Defined in Statistics.Distribution.Gamma

MaybeVariance GeometricDistribution Source # 
Instance details

Defined in Statistics.Distribution.Geometric

MaybeVariance GeometricDistribution0 Source # 
Instance details

Defined in Statistics.Distribution.Geometric

MaybeVariance HypergeometricDistribution Source # 
Instance details

Defined in Statistics.Distribution.Hypergeometric

MaybeVariance LaplaceDistribution Source # 
Instance details

Defined in Statistics.Distribution.Laplace

MaybeVariance LognormalDistribution Source # 
Instance details

Defined in Statistics.Distribution.Lognormal

MaybeVariance NegativeBinomialDistribution Source # 
Instance details

Defined in Statistics.Distribution.NegativeBinomial

MaybeVariance NormalDistribution Source # 
Instance details

Defined in Statistics.Distribution.Normal

MaybeVariance PoissonDistribution Source # 
Instance details

Defined in Statistics.Distribution.Poisson

MaybeVariance StudentT Source # 
Instance details

Defined in Statistics.Distribution.StudentT

MaybeVariance UniformDistribution Source # 
Instance details

Defined in Statistics.Distribution.Uniform

MaybeVariance WeibullDistribution Source # 
Instance details

Defined in Statistics.Distribution.Weibull

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)

Methods

variance :: d -> Double Source #

stdDev :: d -> Double Source #

Instances

Instances details
Variance BetaDistribution Source # 
Instance details

Defined in Statistics.Distribution.Beta

Variance BinomialDistribution Source # 
Instance details

Defined in Statistics.Distribution.Binomial

Variance ChiSquared Source # 
Instance details

Defined in Statistics.Distribution.ChiSquared

Variance DiscreteUniform Source # 
Instance details

Defined in Statistics.Distribution.DiscreteUniform

Variance ExponentialDistribution Source # 
Instance details

Defined in Statistics.Distribution.Exponential

Variance GammaDistribution Source # 
Instance details

Defined in Statistics.Distribution.Gamma

Variance GeometricDistribution Source # 
Instance details

Defined in Statistics.Distribution.Geometric

Variance GeometricDistribution0 Source # 
Instance details

Defined in Statistics.Distribution.Geometric

Variance HypergeometricDistribution Source # 
Instance details

Defined in Statistics.Distribution.Hypergeometric

Variance LaplaceDistribution Source # 
Instance details

Defined in Statistics.Distribution.Laplace

Variance LognormalDistribution Source # 
Instance details

Defined in Statistics.Distribution.Lognormal

Variance NegativeBinomialDistribution Source # 
Instance details

Defined in Statistics.Distribution.NegativeBinomial

Variance NormalDistribution Source # 
Instance details

Defined in Statistics.Distribution.Normal

Variance PoissonDistribution Source # 
Instance details

Defined in Statistics.Distribution.Poisson

Variance UniformDistribution Source # 
Instance details

Defined in Statistics.Distribution.Uniform

Variance WeibullDistribution Source # 
Instance details

Defined in Statistics.Distribution.Weibull

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 BetaDistribution Source # 
Instance details

Defined in Statistics.Distribution.Beta

MaybeEntropy BinomialDistribution Source # 
Instance details

Defined in Statistics.Distribution.Binomial

MaybeEntropy CauchyDistribution Source # 
Instance details

Defined in Statistics.Distribution.CauchyLorentz

MaybeEntropy ChiSquared Source # 
Instance details

Defined in Statistics.Distribution.ChiSquared

MaybeEntropy DiscreteUniform Source # 
Instance details

Defined in Statistics.Distribution.DiscreteUniform

MaybeEntropy ExponentialDistribution Source # 
Instance details

Defined in Statistics.Distribution.Exponential

MaybeEntropy FDistribution Source # 
Instance details

Defined in Statistics.Distribution.FDistribution

MaybeEntropy GammaDistribution Source # 
Instance details

Defined in Statistics.Distribution.Gamma

MaybeEntropy GeometricDistribution Source # 
Instance details

Defined in Statistics.Distribution.Geometric

MaybeEntropy GeometricDistribution0 Source # 
Instance details

Defined in Statistics.Distribution.Geometric

MaybeEntropy HypergeometricDistribution Source # 
Instance details

Defined in Statistics.Distribution.Hypergeometric

MaybeEntropy LaplaceDistribution Source # 
Instance details

Defined in Statistics.Distribution.Laplace

MaybeEntropy LognormalDistribution Source # 
Instance details

Defined in Statistics.Distribution.Lognormal

MaybeEntropy NegativeBinomialDistribution Source # 
Instance details

Defined in Statistics.Distribution.NegativeBinomial

MaybeEntropy NormalDistribution Source # 
Instance details

Defined in Statistics.Distribution.Normal

MaybeEntropy PoissonDistribution Source # 
Instance details

Defined in Statistics.Distribution.Poisson

MaybeEntropy StudentT Source # 
Instance details

Defined in Statistics.Distribution.StudentT

MaybeEntropy UniformDistribution Source # 
Instance details

Defined in Statistics.Distribution.Uniform

MaybeEntropy WeibullDistribution Source # 
Instance details

Defined in Statistics.Distribution.Weibull

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 BetaDistribution Source # 
Instance details

Defined in Statistics.Distribution.Beta

Entropy BinomialDistribution Source # 
Instance details

Defined in Statistics.Distribution.Binomial

Entropy CauchyDistribution Source # 
Instance details

Defined in Statistics.Distribution.CauchyLorentz

Entropy ChiSquared Source # 
Instance details

Defined in Statistics.Distribution.ChiSquared

Entropy DiscreteUniform Source # 
Instance details

Defined in Statistics.Distribution.DiscreteUniform

Entropy ExponentialDistribution Source # 
Instance details

Defined in Statistics.Distribution.Exponential

Entropy FDistribution Source # 
Instance details

Defined in Statistics.Distribution.FDistribution

Entropy GeometricDistribution Source # 
Instance details

Defined in Statistics.Distribution.Geometric

Entropy GeometricDistribution0 Source # 
Instance details

Defined in Statistics.Distribution.Geometric

Entropy HypergeometricDistribution Source # 
Instance details

Defined in Statistics.Distribution.Hypergeometric

Entropy LaplaceDistribution Source # 
Instance details

Defined in Statistics.Distribution.Laplace

Entropy LognormalDistribution Source # 
Instance details

Defined in Statistics.Distribution.Lognormal

Entropy NegativeBinomialDistribution Source # 
Instance details

Defined in Statistics.Distribution.NegativeBinomial

Entropy NormalDistribution Source # 
Instance details

Defined in Statistics.Distribution.Normal

Entropy PoissonDistribution Source # 
Instance details

Defined in Statistics.Distribution.Poisson

Entropy StudentT Source # 
Instance details

Defined in Statistics.Distribution.StudentT

Entropy UniformDistribution Source # 
Instance details

Defined in Statistics.Distribution.Uniform

Entropy WeibullDistribution Source # 
Instance details

Defined in Statistics.Distribution.Weibull

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 if there is not enough data, or if no usable fit results from the method used, e.g., the estimated distribution parameters would be invalid or inaccurate.

Instances

Instances details
FromSample ExponentialDistribution Double Source #

Create exponential distribution from sample. Estimates the rate with the maximum likelihood estimator, which is biased. Returns Nothing if the sample mean does not exist or is not positive.

Instance details

Defined in Statistics.Distribution.Exponential

FromSample LaplaceDistribution Double Source #

Create Laplace distribution from sample. The location is estimated as the median of the sample, and the scale as the mean absolute deviation of the median.

Instance details

Defined in Statistics.Distribution.Laplace

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

Random number generation

class Distribution d => ContGen d where Source #

Generate discrete random variates which have given distribution.

Methods

genContVar :: StatefulGen g m => d -> g -> m Double Source #

Instances

Instances details
ContGen BetaDistribution Source # 
Instance details

Defined in Statistics.Distribution.Beta

ContGen CauchyDistribution Source # 
Instance details

Defined in Statistics.Distribution.CauchyLorentz

ContGen ChiSquared Source # 
Instance details

Defined in Statistics.Distribution.ChiSquared

Methods

genContVar :: StatefulGen g m => ChiSquared -> g -> m Double Source #

ContGen DiscreteUniform Source # 
Instance details

Defined in Statistics.Distribution.DiscreteUniform

ContGen ExponentialDistribution Source # 
Instance details

Defined in Statistics.Distribution.Exponential

ContGen FDistribution Source # 
Instance details

Defined in Statistics.Distribution.FDistribution

Methods

genContVar :: StatefulGen g m => FDistribution -> g -> m Double Source #

ContGen GammaDistribution Source # 
Instance details

Defined in Statistics.Distribution.Gamma

ContGen GeometricDistribution Source # 
Instance details

Defined in Statistics.Distribution.Geometric

ContGen GeometricDistribution0 Source # 
Instance details

Defined in Statistics.Distribution.Geometric

ContGen LaplaceDistribution Source # 
Instance details

Defined in Statistics.Distribution.Laplace

ContGen LognormalDistribution Source # 
Instance details

Defined in Statistics.Distribution.Lognormal

ContGen NormalDistribution Source # 
Instance details

Defined in Statistics.Distribution.Normal

ContGen StudentT Source # 
Instance details

Defined in Statistics.Distribution.StudentT

Methods

genContVar :: StatefulGen g m => StudentT -> g -> m Double Source #

ContGen UniformDistribution Source # 
Instance details

Defined in Statistics.Distribution.Uniform

ContGen WeibullDistribution Source # 
Instance details

Defined in Statistics.Distribution.Weibull

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

Defined in Statistics.Distribution.Transform

Methods

genContVar :: StatefulGen g m => LinearTransform d -> g -> 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

Methods

genDiscreteVar :: StatefulGen g m => d -> g -> m Int Source #

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.