-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Data structures and support functions for working with random processes -- -- RandProc.hs - a Haskell library for working with random processes in a -- mathematically rigorous way (Concepts taken from Random Processes - -- a Mathematical Approach for Engineers by: - Robert M. Gray - Lee -- D. Davisson Prentice-Hall Information and System Sciences Series, -- Thomas Kailath, Series Editor) @package randproc @version 0.4 -- | RandProc.hs - a Haskell library for working with random processes in a -- mathematically rigorous way -- -- (Concepts taken from Random Processes - a Mathematical Approach for -- Engineers by: -- -- -- -- Prentice-Hall Information and System Sciences Series, Thomas Kailath, -- Series Editor) -- -- $Id: RandProc.hs 31 2011-06-22 13:49:48Z dbanas $ -- -- David Banas -- -- 12 March 2011 -- -- Copyright (c) 2011 by David Banas; All rights reserved World wide. -- -- Revision History: -- -- -- -- To Do: module Data.RandProc -- | We take a probability space to consist of the following: -- -- -- -- -- -- data ProbSpace ProbSpace :: [Sample] -> [Measure] -> ProbSpace -- | Measure has 2 fields: -- -- data Measure Measure :: Event -> Double -> Measure -- | This is our abstract data type, which represents a sample in the -- abstract space. -- -- It has a constructor representing every possible element in the -- abstract space we're modeling. (Currently, just points and ranges of -- Doubles.) -- -- Normally, none of the constructors of this type will be called -- directly. Instead, helper functions are provided, such as point -- and range, which hide the implementation details from the user, -- and present a stable interface. -- -- Currently, the sole exception to the above is the Empty -- constructor, which is really just a hack intended to put off the job -- of making the functions in this library more intelligent, with regard -- to their handling of empty lists. data Sample Empty :: Sample -- | Custom data type used for test results and error reporting. data TestResult Fail :: ErrType -> TestResult err :: TestResult -> ErrType Pass :: TestResult -- | Custom data type for reporting different errors data ErrType UnknownErr :: ErrType EmptySampleSpace :: ErrType EmptyEventSpace :: ErrType MissingNullEvent :: ErrType MissingCertainEvent :: ErrType BadEventSamples :: ErrType MissingCompEvent :: ErrType MissingUnionEvent :: ErrType EventMeasLenMismatch :: ErrType DupEventsInMeas :: ErrType MissingEventsInMeas :: ErrType NullEventNonZeroProb :: ErrType CertainEventNonUnityProb :: ErrType EventAndCompNoSumOne :: ErrType -- | Custom data structure, used for constructing individual test cases. -- -- Fields: -- -- data ProbSpaceTest ProbSpaceTest :: ProbSpace -> TestResult -> String -> ProbSpaceTest -- | This is the helper function intended to be used for constructing a -- point sample. point :: Double -> Sample -- | This is the helper function intended to be used for constructing a -- range sample. The range is considered open. That is, its end -- points are not included. range :: (Double, Double) -> Sample -- | This helper function generates a complete and valid probability space, -- given a discrete sample space and set of probabilities. makeProbSpace :: [(Sample, Double)] -> ProbSpace -- | Takes a test case and returns a string indicating the result of the -- test. checkSpace :: ProbSpaceTest -> IO Bool -- | Turns a value of type TestResult into a human readable string. getRsltStr :: TestResult -> String -- | Checks a value of type ProbSpace for correctness, and returns a -- value of type TestResult. checkProbMeas :: ProbSpace -> TestResult -- | Checks whether event space is actually a Sigma field over the sample -- space. checkSigma :: ProbSpace -> TestResult -- | Gets the beginning point of a range, which is not included in -- the range, since ranges are considered to be open. rangeBegin :: Sample -> Double -- | Gets the ending point of a range, which is not included in the -- range, rangeEnd :: Sample -> Double -- | Extracts the probability from a Measure. getProb :: Measure -> Double -- | Extracts the Event from a Measure. getEvent :: Measure -> Event -- | Get the complement of an event from the sample space. getCompEvent :: [Sample] -> Event -> Event -- | Calculates the intersection of 2 events (i.e. - list of samples). eventInt :: Event -> Event -> Event -- | Returns that portion of the first sample that is disjoint from the -- second. smplComp :: Sample -> Sample -> [Sample] -- | Determine if a sample is an element of a space. -- -- (Need this, as opposed to just using elem, in order to -- accomodate ranges.) isElem :: [Sample] -> Sample -> Bool -- | Checks a list of measures against duplicate events. noDupEvents :: [Measure] -> Bool -- | Returns the intersection between 2 samples. smplInt :: Sample -> Sample -> Sample -- | Reduces a list of samples to a single sample representing their -- intersection. smplSetInt :: [Sample] -> Sample -- | Returns the union of 2 samples. -- -- Unlike smplInt, smplUnion must return a list since, if -- the 2 input samples aren't adjacent or overlapping, the union of them -- is a list containing both. smplUnion :: Sample -> Sample -> [Sample] -- | Collapses a list of samples down to the maximally reduced set, which -- still composes a proper union of the input. smplSetUnion :: [Sample] -> [Sample] -- | Power set generator subs :: [a] -> [[a]] instance [overlap ok] Eq Sample instance [overlap ok] Show Sample instance [overlap ok] Eq SampleType instance [overlap ok] Show SampleType instance [overlap ok] Eq Measure instance [overlap ok] Ord Measure instance [overlap ok] Show Measure instance [overlap ok] Show ProbSpace instance [overlap ok] Eq ErrType instance [overlap ok] Show ErrType instance [overlap ok] Show TestResult instance [overlap ok] Eq TestResult instance [overlap ok] Ord Sample