Safe Haskell | Safe |
---|---|

Language | Haskell98 |

- linear :: (RandomGen g, Floating a, Random a, Ord a) => g -> (a, g)
- exponential :: (RandomGen g, Floating a, Random a, Eq a) => a -> g -> (a, g)
- bilExp :: (Floating a, Ord a, Random a, RandomGen g) => a -> g -> (a, g)
- gaussian :: (Floating a, Random a, RandomGen g) => a -> a -> g -> (a, g)
- cauchy :: (Floating a, Random a, RandomGen g, Eq a) => a -> g -> (a, g)
- poisson :: (Num t, Ord a, Floating a, RandomGen g, Random a) => a -> g -> (t, g)
- frequency :: (Floating w, Ord w, Random w, RandomGen g) => [(w, a)] -> g -> (a, g)
- rands :: (RandomGen g, Random a) => (g -> (a, g)) -> g -> [a]

# Random Distributions

linear :: (RandomGen g, Floating a, Random a, Ord a) => g -> (a, g) Source #

Given a random number generator, generates a linearly distributed random variable between 0 and 1. Returns the random value together with a new random number generator. The probability density function is given by

f(x) = 2(1-x) 0 <= x <= 1 = 0 otherwise

:: (RandomGen g, Floating a, Random a, Eq a) | |

=> a | horizontal spread of the function. |

-> g | a random number generator. |

-> (a, g) |

Generates an exponentially distributed random variable given a spread parameter lambda. A larger spread increases the probability of generating a small number. The mean of the distribution is 1/lambda. The range of the generated number is [0,inf] although the chance of getting a very large number is very small.

The probability density function is given by

f(x) = lambda e^(-lambda * x)

:: (Floating a, Ord a, Random a, RandomGen g) | |

=> a | horizontal spread of the function. |

-> g | a random number generator. |

-> (a, g) |

Generates a random number with a bilateral exponential distribution.
Similar to exponential, but the mean of the distribution is 0 and
50% of the results fall between (-1*lambda, 1*lambda).

:: (Floating a, Random a, RandomGen g) | |

=> a | standard deviation. |

-> a | mean. |

-> g | a random number generator. |

-> (a, g) |

Generates a random number with a Gaussian distribution.

:: (Floating a, Random a, RandomGen g, Eq a) | |

=> a | alpha (density). |

-> g | a random number generator. |

-> (a, g) |

Generates a Cauchy-distributed random variable. The distribution is symmetric with a mean of 0.

poisson :: (Num t, Ord a, Floating a, RandomGen g, Random a) => a -> g -> (t, g) Source #

Generates a Poisson-distributed random variable. The given parameter lambda is the mean of the distribution. If lambda is an integer, the probability that the result j=lambda-1 will be as great as that of j=lambda. The Poisson distribution is discrete. The returned value will be a non-negative integer.

frequency :: (Floating w, Ord w, Random w, RandomGen g) => [(w, a)] -> g -> (a, g) Source #

Given a list of weight-value pairs, generates a value randomly picked from the list, weighting the probability of choosing each value by the weight given.