Hi, I just wanted to mention that I have just published Alea, a library to work with random variables.

It is still in a pretty early stage, and some things may not work very well, but this is an example of use:

import alea, future import random/urandom, random/mersenne type Coin = enum Head, Tails proc asInt(x: float): int = x.int lift(asInt) var rng = wrap(initMersenneTwister(urandom(16))) let p = poisson(20).asInt.filter((x: int) => x mod 2 == 0) g = gaussian(mu = 3, sigma = 12).where(p, (t: int) => t > 6) coin = choose(@[Head, Tails]) echo rng.stddev(g) echo rng.sample(coin)

Ok, I looked at it, and I do not really get what

2017-01-11 11:11:22
`where`does. All I got was that it samples from`p`until the condition is true, but then as far as I can see it does not use that value.Well, `filter` samples until a condition is true.

Where conditions on a *different* random variable. It does exactly what you say: it samples from p until the condition in true, then return what g samples in that point.

The example above is really artificial, since the two random variables are independent, but when the two variables are dependent it may very well be important. Think of all the problems like "What is the expected value of something knowing that something else..."