factory-0.3.0.0: Rational arithmetic in an irrational world.

Safe HaskellNone
LanguageHaskell2010

Factory.Math.Probability

Contents

Description

AUTHOR
Dr. Alistair Ward
DESCRIPTION
Functions for probability-distributions.
CAVEAT
Because data-constructors are exposed, isValid need not be called.

Synopsis

Type-classes

class Distribution probabilityDistribution where Source #

Defines a common interface for probability-distributions.

Minimal complete definition

generatePopulation, getMean

Methods

generatePopulation :: (Fractional sample, RandomGen randomGen) => probabilityDistribution -> randomGen -> [sample] Source #

getMean :: Fractional mean => probabilityDistribution -> mean Source #

getStandardDeviation :: Floating standardDeviation => probabilityDistribution -> standardDeviation Source #

getVariance :: Floating variance => probabilityDistribution -> variance Source #

Instances

(RealFloat parameter, Show parameter, Random parameter) => Distribution (DiscreteDistribution parameter) Source # 

Methods

generatePopulation :: (Fractional sample, RandomGen randomGen) => DiscreteDistribution parameter -> randomGen -> [sample] Source #

getMean :: Fractional mean => DiscreteDistribution parameter -> mean Source #

getStandardDeviation :: Floating standardDeviation => DiscreteDistribution parameter -> standardDeviation Source #

getVariance :: Floating variance => DiscreteDistribution parameter -> variance Source #

(RealFloat parameter, Show parameter, Random parameter) => Distribution (ContinuousDistribution parameter) Source # 

Methods

generatePopulation :: (Fractional sample, RandomGen randomGen) => ContinuousDistribution parameter -> randomGen -> [sample] Source #

getMean :: Fractional mean => ContinuousDistribution parameter -> mean Source #

getStandardDeviation :: Floating standardDeviation => ContinuousDistribution parameter -> standardDeviation Source #

getVariance :: Floating variance => ContinuousDistribution parameter -> variance Source #

Types

Data-types

data ContinuousDistribution parameter Source #

Constructors

ExponentialDistribution parameter

Defines an Exponential-distribution with a particular lambda; https://en.wikipedia.org/wiki/Exponential_distribution.

LogNormalDistribution parameter parameter

Defines a distribution whose logarithm is normally distributed with a particular mean & variance; https://en.wikipedia.org/wiki/Lognormal.

NormalDistribution parameter parameter

Defines a Normal-distribution with a particular mean & variance; https://en.wikipedia.org/wiki/Normal_distribution.

UniformDistribution (Interval parameter)

Defines a Uniform-distribution within a closed interval; https://en.wikipedia.org/wiki/Uniform_distribution.

Instances

Eq parameter => Eq (ContinuousDistribution parameter) Source # 

Methods

(==) :: ContinuousDistribution parameter -> ContinuousDistribution parameter -> Bool #

(/=) :: ContinuousDistribution parameter -> ContinuousDistribution parameter -> Bool #

Read parameter => Read (ContinuousDistribution parameter) Source # 
Show parameter => Show (ContinuousDistribution parameter) Source # 
(Floating parameter, Ord parameter, Show parameter) => SelfValidator (ContinuousDistribution parameter) Source # 
(RealFloat parameter, Show parameter, Random parameter) => Distribution (ContinuousDistribution parameter) Source # 

Methods

generatePopulation :: (Fractional sample, RandomGen randomGen) => ContinuousDistribution parameter -> randomGen -> [sample] Source #

getMean :: Fractional mean => ContinuousDistribution parameter -> mean Source #

getStandardDeviation :: Floating standardDeviation => ContinuousDistribution parameter -> standardDeviation Source #

getVariance :: Floating variance => ContinuousDistribution parameter -> variance Source #

data DiscreteDistribution parameter Source #

Constructors

PoissonDistribution parameter

Defines an Poisson-distribution with a particular lambda; https://en.wikipedia.org/wiki/Poisson_distribution.

ShiftedGeometricDistribution parameter

Defines an Geometric-distribution with a particular probability of success; https://en.wikipedia.org/wiki/Geometric_distribution.

Instances

Eq parameter => Eq (DiscreteDistribution parameter) Source # 

Methods

(==) :: DiscreteDistribution parameter -> DiscreteDistribution parameter -> Bool #

(/=) :: DiscreteDistribution parameter -> DiscreteDistribution parameter -> Bool #

Read parameter => Read (DiscreteDistribution parameter) Source # 
Show parameter => Show (DiscreteDistribution parameter) Source # 

Methods

showsPrec :: Int -> DiscreteDistribution parameter -> ShowS #

show :: DiscreteDistribution parameter -> String #

showList :: [DiscreteDistribution parameter] -> ShowS #

(Num parameter, Ord parameter, Show parameter) => SelfValidator (DiscreteDistribution parameter) Source # 

Methods

getErrors :: DiscreteDistribution parameter -> [String] #

isValid :: DiscreteDistribution parameter -> Bool #

(RealFloat parameter, Show parameter, Random parameter) => Distribution (DiscreteDistribution parameter) Source # 

Methods

generatePopulation :: (Fractional sample, RandomGen randomGen) => DiscreteDistribution parameter -> randomGen -> [sample] Source #

getMean :: Fractional mean => DiscreteDistribution parameter -> mean Source #

getStandardDeviation :: Floating standardDeviation => DiscreteDistribution parameter -> standardDeviation Source #

getVariance :: Floating variance => DiscreteDistribution parameter -> variance Source #

Functions

maxPreciseInteger :: RealFloat a => a -> Integer Source #

The maximum integer which can be accurately represented as a Double.

boxMullerTransform Source #

Arguments

:: (Floating f, Ord f, Show f) 
=> (f, f)

Independent, uniformly distributed random numbers, which must be within the semi-closed unit interval, (0,1].

-> (f, f)

Independent, normally distributed random numbers, with standardized mean=0 and variance=1.

generateStandardizedNormalDistribution :: (RealFloat f, Show f, Random f, RandomGen randomGen) => randomGen -> [f] Source #

generateContinuousPopulation Source #

Arguments

:: (RealFloat f, Show f, Random f, RandomGen randomGen) 
=> ContinuousDistribution f 
-> randomGen

A generator of uniformly distributed random numbers.

-> [f] 

Uses the supplied random-number generator, to generate a conceptually infinite population, with the specified continuous probability-distribution.

generateDiscretePopulation Source #

Arguments

:: (Integral sample, Ord parameter, RealFloat parameter, Show parameter, Random parameter, RandomGen randomGen) 
=> DiscreteDistribution parameter 
-> randomGen

A generator of uniformly distributed random numbers.

-> [sample] 

Uses the supplied random-number generator, to generate a conceptually infinite population, with the specified discrete probability-distribution.