# How to Generate Random Numbers: Poisson Distribution

From Q

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;

This example is based upon the first answer on stackoverflow.

## See Also

- JavaScript Variables for detail on how to create new variables in the Variables and Questions tab using JavaScript.
- JavaScript for information about the JavaScript programming language.
- How to Generate Random Numbers: Uniform Distribution from 0 to 1.