diff options
Diffstat (limited to 'src/utils.c')
-rw-r--r-- | src/utils.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/utils.c b/src/utils.c index d5e1b874..faf78502 100644 --- a/src/utils.c +++ b/src/utils.c @@ -71,3 +71,25 @@ void progress_bar(int val, int total) fflush(stdout); } + + +double poisson_noise(double expected) +{ + double L; + int k; + double p = 1.0; + + L = exp(-expected); + + do { + + double r; + + k++; + r = (double)random()/RAND_MAX; + p *= r; + + } while ( p > L ); + + return k - 1; +} |