Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
First N Packet Poisson Arrival Times
function firstNPacketPoissonArrivals(n, rate, t) {
n--;
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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.