JSFiddle - React, Tailwind, and code Playground

by Graham Fairweather

HTML

<div id="result"></div>

JavaScript

function poissonRandomNumber(lambda) {
    var L = Math.exp(-lambda),
        k = 0,
        p = 1;

    do {
        k = k + 1;
        p = p * Math.random();
    } while (p > L);

    return k - 1;
}

document.getElementById("result").textContent = poissonRandomNumber(100);