# Random Processes

RandProc is a Haskell library, which defines and supports certain data structures that are convenient when working with random processes in a mathematically rigorous fashion.

The concepts embedded in RandProc come from the text I used in my graduate stochastic processes course:

Robert M. Gray, Lee D. Davisson; *Random Processes - a Mathematical Approach for Engineers*; Prentice-Hall Information and System Sciences Series, Thomas Kailath, Series Editor.

*Authors: David Banas*

## Contents

## Installation

Download the `randproc` package:

$ cabal install randproc

and import it:

import Data.RandProc

## Description

### Underlying concepts

As per the reference text, a *probability space* is taken to be composed of:

- an
**abstract space**of samples, - an
**event space**, which must be a sigma field over the abstract sample space, and - a
**probability measure**over the event space.

In the code, the *event space* and *probability measure* are combined, in order to keep the code concise.

### Public interface

#### New data types

The code defines an abstract data type, *Sample*, as follows:

data Sample = Point Double | Range (Double, Double) | Empty | Full deriving (Eq, Show)

However, this type is not exported in the public interface of the `RandProc` module. Instead, helper functions *point* and *range* are provided, as alternatives, in order to protect against future implementation changes.

*Note) There is, currently, a single exception to the above. The *Empty* value constructor *is* exported, as it is currently necessary. However, this is really just a hack designed to put off the task of making the support functions more intelligent, with regards to their handling of empty sample sets.*

An event is defined in the code as simply an alias for a list of samples:

type Event = [Sample]

And a measure just attaches a probability of occurrence to an event:

data Measure = Measure { event :: Event ,prob :: Double } deriving (Eq, Ord, Show)

#### Supporting functions

Several supporting functions are provided for working with the new data types described, above. A few of the more interesting examples are given, below. For a complete list, refer to the documentation.

- checkProbMeas
- Checks a value of type 'ProbSpace' for correctness, and returns a value of type 'TestResult'.

- checkSigma
- Checks whether event space is actually a Sigma field over the sample space.

- smplSetUnion
- Collapses a list of samples down to the maximally reduced set, which still composes a proper union of the input.

- smplSetInt
- Reduces a list of samples to a single sample representing their intersection.

## Usage

For more extensive usage examples, see the `test/Test.hs` file.

### Construction of a probability space representing a fair coin

fairCoin = ProbSpace [point 0.0, point 1.0] [Measure ( [Empty]) 0, Measure ( [point 0]) 0.5 , Measure ( [point 1]) 0.5, Measure ( [point 0, point 1]) 1.0]

### Testing the probability space defined, above

checkProbMeas fairCoin

## Documentation

The documentation for this library is generated, via Haddock.

## Related work

I suspect a potential symbiosis between this library and Probabilistic Functional Programming

## Community

- RandProcNotes
- Blog dedicated to the `RandProc` Haskell library