factory-0.2.1.1: Rational arithmetic in an irrational world.

Safe HaskellNone
LanguageHaskell98

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 Source

Arguments

:: (Fractional sample, RandomGen randomGen) 
=> probabilityDistribution 
-> randomGen

A generator of uniformly distributed random numbers.

-> [sample]

CAVEAT: the integers generated for discrete distributions are represented by a fractional type; use generateDiscretePopulation if this is a problem.

getMean Source

Arguments

:: Fractional mean 
=> probabilityDistribution 
-> mean

The theoretical mean.

getStandardDeviation Source

Arguments

:: Floating standardDeviation 
=> probabilityDistribution 
-> standardDeviation

The theoretical standard-deviation.

getVariance Source

Arguments

:: Floating variance 
=> probabilityDistribution 
-> variance

The theoretical variance.

Instances

(RealFloat parameter, Show parameter, Random parameter) => Distribution (DiscreteDistribution parameter) 
(RealFloat parameter, Show parameter, Random parameter) => Distribution (ContinuousDistribution parameter) 

Types

Data-types

data ContinuousDistribution parameter Source

Constructors

ExponentialDistribution parameter

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

LogNormalDistribution parameter parameter

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

NormalDistribution parameter parameter

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

UniformDistribution (Interval parameter)

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

Instances

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

data DiscreteDistribution parameter Source

Constructors

PoissonDistribution parameter

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

ShiftedGeometricDistribution parameter

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

Instances

Eq parameter => Eq (DiscreteDistribution parameter) 
Read parameter => Read (DiscreteDistribution parameter) 
Show parameter => Show (DiscreteDistribution parameter) 
(Num parameter, Ord parameter, Show parameter) => SelfValidator (DiscreteDistribution parameter) 
(RealFloat parameter, Show parameter, Random parameter) => Distribution (DiscreteDistribution parameter) 

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.