haskell / mwc-random

A very fast Haskell library for generating high quality pseudo-random numbers.
http://hackage.haskell.org/package/mwc-random
BSD 2-Clause "Simplified" License
55 stars 25 forks source link

Generators for Poisson and Binomial distributions with different tradeoffs #27

Open Shimuuar opened 10 years ago

Shimuuar commented 10 years ago

Currently library allows to generate Poisson and binomial random variate using condensed tables algorithm. It is very fast but require building lookup table which is costly. It makes this algorithm unsuitable for cases when only few samples for given parameters are required. For examples when parameters are random variables themselves

Shimuuar commented 9 years ago

There's post about algorithm for generation of Poisson random variates. Algorithm is noce and simple but requires dependency on math-functions (it needs logFactorial).

http://www.johndcook.com/blog/2010/06/14/generating-poisson-random-values/

cspollard commented 7 years ago

I am trying to figure out whether the issue I have is related. My system is using many GB (I last stopped it at 25 GB!) of memory to do something that perhaps ought to be simple:

> withSystemRandom . asGenIO . sample $ poisson 10000

I guess this is from the table generation. Is this expected given the current setup?

Shimuuar commented 7 years ago

Yes. It's problem with condensed tables. See #59

jarandaf commented 7 years ago

This is what R uses, might be of help for a possible implementation.

Shimuuar commented 7 years ago

Thank you! Although I don't think I'll have time anytime soon