如何生成具有特定概率密度函数的随机数? [英] How to generate a random number with a specific probability density function?

查看:451
本文介绍了如何生成具有特定概率密度函数的随机数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为移动无线网络建模阴影和快速衰落.对于快速衰落,瑞利衰落是可以使用的合理模型.信道响应的包络将是瑞利分布的.调用此随机变量R,它将具有

I am trying to model shadowing and fast fading for mobile wireless networks. For fast fading, Rayleigh fading is a reasonable model to use. The envelope of the channel response will be Rayleigh distributed. Calling this random variable R, it will have a probability density function (PDF) of

PR(r)=((2r)/Ω)* exp(-r ^ 2/Ω),r> = 0,Ω=2σ^ 2

PR(r) = ((2r)/Ω)*exp(-r^2/Ω), r >= 0, Ω = 2σ^2

http://en.wikipedia.org/wiki/Rayleigh_fading 来查看等式写得很好.

http://en.wikipedia.org/wiki/Rayleigh_fading to see the equation written nicely.

所以,我有PDF,现在我只是想知道如何从中获取随机变量?

So, I have the PDF, now I am just wondering how to get the random variable from it?

我已经看过以下问题:

生成数字数组符合Ruby中的概率分布?

生成具有概率分布的随机数

但是我仍然不确定该怎么做.我花了我一生的时间来理解PDF,所以如果有人知道Java中获取特定PDF随机变量的方法,将不胜感激!

but I am still not sure how to do it. It has taken me forever to understand PDF's so if anyone knows a way in Java to get a random variable with a specific PDF, that would be much appreciated!

推荐答案

瑞利分布是的特例威布尔分布.如果您四处搜索,那么有很多用Java编写的Weibull生成器,例如:

Rayleigh distribution is a special case of the Weibull distribution. If you google around, there are lots of Weibull generators written in Java, for example:

  • http://commons.apache.org/math/apidocs/org/apache/commons/math3/distribution/WeibullDistribution.html
  • http://www.iro.umontreal.ca/~simardr/ssj/doc/html/umontreal/iro/lecuyer/randvar/WeibullGen.html
  • http://www.icsa.inf.ed.ac.uk/research/groups/hase/simjava/distributions/doc/eduni/distributions/Weibull.html
  • http://www.ee.ucl.ac.uk/~mflanaga/java/PsRandom.html

一种从给定分布中生成随机数的方法是生成一个在零和一之间均匀分布的随机数,然后应用目标分布的反数 CDF 到该随机数.参见维基百科.

One way to generate a random number from a given distribution is to generate a random number uniformly distributed between zero and one, and apply the target distribution's inverse CDF to that random number. See Wikipedia.

这篇关于如何生成具有特定概率密度函数的随机数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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