NAME

Math::StochasticProcess - Stochastic Process

VERSION

Version 0.01

SYNOPSIS

use Math::StochasticProcess;

my $analysis = Math::StochasticProcess->new(seed_event=>It_all_started_here=>new,
                                        tolerance=>0.0001);
$analysis->run();
print $analysis->event("Dont_worry_It_might_never_happen")->probability();
...

DESCRIPTION

This set of modules is designed to faciliate the calculation of probabilities and expected values from stochastic processes. The basic module is the Math::StochasticProcess::Event, from which you derive classes which specify which Events follow from a given Event and by which probability. This class has a "iterate" method which returns an array of new events. This "iterate" method is equivalent to the stochastic matrix. Critically this class has an "isResolved" virtual method. You kick off the module by creating a Math::StochasticProcess object. Its constructor takes as its argument a seed Event. When run, the StochasticProcess iterates until all events are resolved.

In this way the Math::StochasticProcess and Math::StochasticProcess::Event modules are all that are required to use this package. The Math::StochasticProcess::Event module is intentionally left "pure virtual" so that you can implement your own efficient Event classes. A full working example is given below. However if this is not enough you can use the Math::StochasticProcess::Event::Tuple boilerplate class which can be used either as is or as a base class.

FUNCTIONS

new

This is a standard constructor function. The arguments are as follows:

seed_event

This mandatory argument must be an instance of the Math::StochasticProcess::Event class and its probability must be 1.

tolerance

This defaults to 0.00001. It specifies the probability below which we just throw events away.

soft_sanity_level

If specified this determines how far we allow the sum of all probabilities to diverge from 1, before warning.

hard_sanity_level

If specified this determines how far we allow the sum of all probabilities to diverge from 1, before dieing.

log_file_handle

If specified this should be a FileHandle object to which we write our debug statements.

run

This is the core function of the whole package. It iterates from the seed event until no unresolved events remain. Once it completes the object can be queried for the results.

event

This returns the result of the run. With no additional parameters it runs a list of signatures and events which can be put in a hash. Otherwise it takes as a single non-object parameter a signature and returns the corresponding event.

expectedValue

This is another function returning the result of the run. With no additional parameters it runs a list of random variable names and their expected terminal values. This list can be put into a hash. Otherwise it takes as a single non-object parameter a random variable name and returns the corresponding expected value.

_calculateExpectedValue

Internal function. Used by "expectedValue".

_numUnresolved

The number of unresolved events.

_sanityCheck

Ideally should always be zero, but must at least be close.

_iterate

Internal function. Essentially one round in the "run" function.

_merge

Internal function. Called inside "run" function when in case two events are essentially the same.

AUTHOR

Nicholas Bamber, <theabbot at silasthemonk.org.uk>

BUGS

Please report any bugs or feature requests to bug-math-pea at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Math-StochasticProcess. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Math::StochasticProcess

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2008 Nicholas Bamber, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.