factory-0.2.0.4: Rational arithmetic in an irrational world.

Safe HaskellSafe-Infered

Factory.Math.Probability

Contents

Description

AUTHOR
Dr. Alistair Ward
DESCRIPTION
Miscellaneous functions for probability-distributions.

Synopsis

Types

Data-types

data ContinuousDistribution f Source

Constructors

UniformDistribution (Interval f)

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

NormalDistribution f f

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

Functions

boxMullerTransformSource

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

generateContinuousPopulationSource

Arguments

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

number of items.

-> ContinuousDistribution f 
-> randomGen

A generator of uniformly distributed random numbers.

-> [f] 
  • Generates a random sample-population, with the specified continuous probability-distribution.
  • When a Normal distribution is requested, the generated population will only tend towards the requested mean and variance of, as the sample-size tends towards infinity. Whilst one could arrange for these criteria to be precisely met for any sample-size, the sample would lose a degree of randomness as a result.

generatePoissonDistributionSource

Arguments

:: (Integral events, RealFloat lambda, Show lambda, Random lambda, RandomGen randomGen) 
=> lambda

Defines the required approximate value of both mean and variance.

-> randomGen 
-> [events] 
  • Uses the supplied random-number generator, to generate a conceptually infinite list, of random integers conforming to the Poisson distribution (mean=lambda, variance=lambda).
  • http://en.wikipedia.org/wiki/Poisson_distribution.
  • CAVEAT: uses an algorithm by Knuth, which having a linear time-complexity in lambda, can be intolerably slow; also, the term exp $ negate lambda, underflows for large lambda; so for large lambda, this implementation returns the appropriate NormalDistribution, which is similar for large lambda.

generateDiscretePopulationSource

Arguments

:: (Ord f, RealFloat f, Show f, Random f, RandomGen randomGen, Integral events) 
=> Int

number of items.

-> DiscreteDistribution f 
-> randomGen

A generator of uniformly distributed random numbers.

-> [events] 

Generates a random sample-population, with the specified discrete probability-distribution.