## Introduction

Generate random numbers with a Poisson distribution with some JavaScript.

## Method

Create a new JavaScript variable with the following **Expression**, where you replace `5` with your desired mean:

```
var mean = 5;
var L = Math.exp(-mean);
var p = 1.0;
var k = 0;
do {
k++;
p *= Math.random();
} while (p > L);
k - 1;
```

## Comments

0 comments

Article is closed for comments.