Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
First N Packet Poisson Arrival Times
function firstNPacketPoissonArrivals(n, rate, t) {
t = t || 0;
var u, x;
var lambda = rate;
u = Math.random(); // random value between [0, 1]
x = (-1/lambda)*Math.log(1-u);
t = t + x;
console.log('Arrival of packet at time: ' + t);
if (n > 0) {
firstNPacketPoissonArrivals(n, rate, t);
firstNPacketPoissonArrivals(10, 3);
You can’t perform that action at this time.