泊松变量,λ连接和到达率,Java网络模拟
我正在开发一个网络模拟器,其中数据包到达和传输尝试的事件遵循泊松分布。我对 Knuth 算法进行了改编:
public class Poisson {
private double λ;
private Random rand;
/** Creates a variable with a given mean. */
public Poisson(double λ) {
this.λ = λ;
rand = new Random();
}
public int next() {
double L = Math.exp(-λ);
double p = 1.0;
int k = 0;
do {
k++;
p *= rand.nextDouble();
} while (p > L);
return k - 1;
}
}
我的规范规定节点使用泊松过程随机重新安排楼层。平均到达间隔时间呈指数分布,平均值 Ts = 2.5ms。我使用 λ = 2.5 是否正确?
当我想要创建一个新到达事件时,我会执行以下操作:
Event evt = new Event(EventType.ARRIVAL_EVENT,
MasterClock.getTime + poisson.next());
eventList.add(evt);
模拟器应该运行多次,每次都会增加负载来测量性能。起初我认为到达率等于 λ,但 λ 越大,每秒收到的数据包就越少。到达率和λ之间有什么关系? 我对这篇很长的文章感到抱歉,但我真的很沮丧,因为在大量大学书籍和整个互联网上搜索却没有有效的网络模拟来源......
提前感谢您的帮助。
I'm developing a network simulator in which events for packet arrivals and transmission attempts are following a Poisson distribution. I have an adaptation of Knuth's algorithm:
public class Poisson {
private double λ;
private Random rand;
/** Creates a variable with a given mean. */
public Poisson(double λ) {
this.λ = λ;
rand = new Random();
}
public int next() {
double L = Math.exp(-λ);
double p = 1.0;
int k = 0;
do {
k++;
p *= rand.nextDouble();
} while (p > L);
return k - 1;
}
}
My specs state that nodes reschedule floors randomly with a Poisson process. The average interarrival time is exponentially distributed with mean of Ts = 2.5ms. Am I correct in using λ = 2.5?
When I want to make an new arrival event I do something like:
Event evt = new Event(EventType.ARRIVAL_EVENT,
MasterClock.getTime + poisson.next());
eventList.add(evt);
The simulator is supposedly running several times, every time with increased load to measure performance. At first I thought that the arrival rate equals λ but the bigger the λ the less packets per second I get. What is the relationship between arrival rate and λ?
I am sorry for the very long post but I am really frustrated by searching in lots of university books and all over the internet without a valid source for network simulation...
Thank you in advance for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可能看起来很奇怪,但对于泊松过程,您不需要泊松分布,而是指数分布。查看维基百科。
您在代码中模拟的到达间隔时间遵循参数 lambda 的指数分布 = 1 / 2.5(lambda 是平均值的倒数)。您可以使用 -Math.log(1.0 - rand.nextDouble()) / lambda 轻松获得随机指数变量。
泊松过程有两种视图: 上述视图保持事件数量固定 (1),而时间间隔变化。另一种观点保持时间间隔固定,但该间隔内的事件数量是随机变量(并遵循泊松分布)。
It might seem weird, but for your Poisson process, you don't need the Poisson distribution but the exponential distribution. Look on wikipedia.
The inter-arrival times, which you are simulating in your code, follow the exponential distribution of parameter lambda = 1 / 2.5 (lambda is the inverse of the mean). You can easily get a random exponential variate with -Math.log(1.0 - rand.nextDouble()) / lambda.
There are two views of the Poisson process: The view described above keeps the number of events fixed (1) and the time interval varies. The other view keeps the time interval fixed, but the number of events in that interval is the random variate (and follows the Poisson distribution).
?Ts 是一个时间。 λ 是到达速率, 以每秒的项目数为单位。请参阅William Stallings,队列分析。
No. Ts is a time. λ is the arrival rate, in items per second. See William Stallings, Queueing Analysis.