伪随机数发生器 - 指数分布 [英] Pseudorandom Number Generator - Exponential Distribution

查看:375
本文介绍了伪随机数发生器 - 指数分布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想产生一些伪随机数和到现在为止我已经非常知足了。NET库的 Random.Next(INT分钟,INT最大)功能。该品种的PRNG是的应该的使用均匀分布,但我非常想使用指数分布产生一些数字。

I would like to generate some pseudorandom numbers and up until now I've been very content with the .Net library's Random.Next(int min, int max) function. PRNGs of this variety are supposed to be using a Uniform distribution, but I would very much like to generate some numbers using an Exponential Distribution.

我在C#编程,不过我会接受伪code或C ++,Java或类似。

I'm programming in C#, although I'll accept pseudocode or C++, Java or the like.

任何建议/ code片段/算法/想法?

Any suggestions / code snippets / algorithms / thoughts?

推荐答案

既然你有机会到一个统一的随机数发生器,产生一个随机数分布与其他分布的CDF你知道是很容易使用的反演方法

Since you have access to a uniform random number generator, generating a random number distributed with other distribution whose CDF you know is easy using the inversion method.

于是,产生均匀的随机数, U [0,1),然后计算 X 是:

So, generate a uniform random number, u, in [0,1), then calculate x by:

X =日志(1-U)/(&负;&拉姆达;

x = log(1-u)/(−λ),

在这里和拉姆达;是指数分布的速率参数。现在, X 是一个随机数与指数分布。需要注意的是日志上面 LN ,自然对数。

where λ is the rate parameter of the exponential distribution. Now, x is a random number with an exponential distribution. Note that log above is ln, the natural logarithm.

这篇关于伪随机数发生器 - 指数分布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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