Portability | portable |
---|---|

Stability | experimental |

Maintainer | forsyde-dev@ict.kth.se |

The stochastic library provides a few stochastic skeletons, which are
relatives to the skeletons of the synchronous library. These skeletons are
based on two elementary functions, `sigmaUn`

and `sigmaGe`

which provide stochastic signals. The background and motivation for this
approach is described in the paper

Axel Jantsch, Ingo Sander, and Wenbiao Wu,
"The usage of stochastic processes in embedded system specifications",
In *Proceedings of the Ninth International Symposium on Hardware and Software Codesign*,
April 2001 (http://web.it.kth.se/~axel/papers/2001/codes-2001.pdf).

Unfortunately, not all of the suggested skeletons are implemented. In particular, consolidation-based process constructors and all constructors for the untimed and the discrete timed MoCs are missing.

- selMapSY :: Int -> (a -> b) -> (a -> b) -> Signal a -> Signal b
- selScanlSY :: Int -> (a -> b -> a) -> (a -> b -> a) -> a -> Signal b -> Signal a
- selMealySY :: Int -> Int -> (a -> b -> a) -> (a -> b -> a) -> (a -> b -> c) -> (a -> b -> c) -> a -> Signal b -> Signal c
- selMooreSY :: Int -> Int -> (a -> b -> a) -> (a -> b -> a) -> (a -> c) -> (a -> c) -> a -> Signal b -> Signal c
- sigmaUn :: Int -> (Int, Int) -> Signal Int
- sigmaGe :: (Float -> Float) -> Int -> (Int, Int) -> Signal Int

# Select based synchronous process constructors

:: Int | The seed |

-> (a -> b -> a) | The first alternative next-state function |

-> (a -> b -> a) | The second alternative function |

-> a | The initial state |

-> Signal b | The input signal |

-> Signal a | The output signal |

The skeleton `selScanlSY`

is a stochastic variant of `scanlSY`

.

:: Int | The seed for the next-state function |

-> Int | The seed for the output function |

-> (a -> b -> a) | First alternative for the next-state function |

-> (a -> b -> a) | Second alternative for the next-state function |

-> (a -> b -> c) | First alternative for the output function |

-> (a -> b -> c) | Second alternative for the output function |

-> a | The initial state |

-> Signal b | The input signal |

-> Signal c | The output signal |

`selMealySY`

is the stochastic variant of mealySY. Both the
next-state and the output function is randomly selected based on a
uniform distribution.

:: Int | The seed for the next-state function |

-> Int | The seed for the output function |

-> (a -> b -> a) | First alternative for the next-state function |

-> (a -> b -> a) | Second alternative for the next-state function |

-> (a -> c) | First alternative for the output function |

-> (a -> c) | Second alternative for the output function |

-> a | The initial state |

-> Signal b | The input signal |

-> Signal c | The output signal |

`selMooreSY`

is the stochastic variant of mooreSY. Both the
next-state and the output function is randomly selected based on a
uniform distribution.

# Elementary stochastic processes

:: Int | The seed |

-> (Int, Int) | The interval from which the stochastic values are taken |

-> Signal Int | The sequence of stochastic values |

`sigmaUn`

generates a signal list of uniformly distributed Int within
the given range and with a given seed.

:: (Float -> Float) | The stochastic distribution |

-> Int | The seed |

-> (Int, Int) | The range |

-> Signal Int | The sequence of stochastic values |

`sigmaGe`

is a more general stochastic process. The first argument is a
function f which describes the distribution. For each value v in the
given range (r1,r2), f(v) is the probability that v is generated.

Note, that the user has to make sure that sum(f(v))=1 for v in (r1,r2).

For illustration consider the following example.

pdist :: Float -> Float pdist d = 1\/\(2**d\) pdistsum 1 = pdist 1 pdistsum d = \(pdist d\) + \(pdistsum \(d-1\)\)

pdistnorm :: Float -> Float -> Float pdistnorm dmax d = 1\/((pdistsum dmax) * (2**d))

`pdistnorm dmax d`

gives the probability of a value <= d;

`pdistnorm dmax dmax`

is always 1.0

Hence, using pdistnorm as a function in `sigmaGe`

gives an exponantial
distribution for values in the range [0, dmax].