用于泊松和均匀分布的Java生成器? [英] Java Generator for Poisson and Uniform Distributions?

查看:714
本文介绍了用于泊松和均匀分布的Java生成器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,标准发生器用于正态分布。我必须根据正态,均匀和泊松分布生成随机数,但我似乎找不到最后2的类。

From what I understand, the standard generator is for the Normal Distribution. I have to generate random numbers according to the Normal, Uniform and Poisson Distributions, but I can't seem to find a class for the last 2.

我必须生成它们在0 - 999999范围内。

I have to generate them in the range of 0 - 999999.

推荐答案

正如大卫指出的那样,提供的伪随机数发生器使用了统一分配。

As David has pointed out, the supplied pseudo-random number generator uses the Uniform distribution.

对于其他两个,我会使用 Cern Colt 库函数:

For the other two, I would use the Cern Colt library functions:

  • Poisson
  • Normal/Gaussian

这些库函数可以让您轻松地找到从每个分布中获取的随机数,而不是给出概率密度函数或累积函数密度函数并期望您自己推导出数字(这似乎是Apache Commons-Math方法):

These library functions easily allow you to find a random number taken from each distribution, rather than giving you a probability density function or cumulative density function and expecting you to derive the number yourself (which seems to be the Apache Commons-Math approach):

RandomEngine engine = new DRand();
Poisson poisson = new Poisson(lambda, engine);
int poissonObs = poisson.nextInt();

Normal normal = new Normal(mean, variance, engine);
double normalObs = normal.nextDouble();

另外,请记住Poisson分布P(λ)适用于大型λ可以用正态分布N(λ,sqrt(λ))非常接近。

Also, bear in mind that the Poisson distribution P(λ) for large λ can be approximated very well by the normal distribution N(λ, sqrt(λ)).

这篇关于用于泊松和均匀分布的Java生成器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆