NAME

Statistics::Distribution::Generator - A way to compose complicated probability functions

VERSION

Version 0.003

SYNOPSIS

use Statistics::Distribution::Generator qw( :all );
my $g = gaussian 3, 1;
say $g; # something almost certainly between -3 and 9, but probably about 2 .. 4-ish
my $cloud = (gaussian 0, 1 x gaussian 0, 1 x gaussian 0, 1);
say @$cloud; # a 3D vector almost certainly within (+/- 6, +/- 6, +/- 6) and probably within (+/- 2, +/- 2, +/- 2)
my $combo = (gaussian 100, 15 | uniform 0, 200); # one answer with an equal chance of being picked from either distribution

DESCRIPTION

This module allows you to bake together multiple "simple" probability distributions into a more complex random number generator.

EXPORTABLE FUNCTIONS

gaussian MEAN, SIGMA

Gaussian Normal Distribution

uniform MIN, MAX

A uniform distribution, with equal chance of any n where MIN <= n < MAX

logistic

Standard Logistic Distribution

supplied VALUE
supplied CALLBACK

Allows the caller to supply either a constant VALUE which will always be returned, or a coderef CALLBACK that may use any algorithm you like to generate a random number

gamma ORDER, SCALE

Gamma Distribution

The distribution function is

p(x) dx = {1 \over \Gamma(a) b^a} x^{a-1} e^{-x/b} dx
for x > 0.

OVERLOADED OPERATORS

x

Allows you to compose multi-dimensional random vectors.

$randvect = $foo x $bar x $baz; # generate a three-dimensional vector
|

Allows you to pick a single (optionally weighted) generator from some set of generators.

$cointoss = supplied 0 | supplied 1; # fair 50:50 result of either 0 or 1

AUTHOR

The main body of this work is by Paul W Bennett

The idea of composing probabilities together comes from a paper by TODO: CITE THE PAPER HERE

The implementation of the Gamma Distribution is by Nigel Wetters Gourlay.

CAVEATS

Almost no error checking is done. Garbage in will result in garbage out.

TODO

Build in more probability density functions.

LICENSE

Artistic 2.0