问题描述
我需要一个随机数发生器,用于产生n和m之间的各种数,但没有用相同的概率。我想设置n和m之间的值x,其中的可能性是最高的:
I need a random number generator that generates various number between n and m, but no with a equal probability. I want to set a value x between n and m where the possibility is the highest:
有没有一种简单的方法来做到这一点使用Random类?的可能性应该有一个二项式分布或类似的形式(这并不重要,它的精确二项式分布特征研究,粗糙近似,也行)
Is there an easy way to do that using the Random class? The likelihood should have the form of a binominal distribution or something similar (it is not important that its an exact binominal distributon, rough approximations are also ok)
也许我要澄清:我不是在寻找一个二项式或高斯分布,而且这样的事情:
Maybe I have to clarify: I'm not looking for a binominal or gaussian distribution but also for something like this:
欲定义的值x,其中最高的可能性应
I want to to define the value x where the highest likelihood should be.
不幸的是,previously接受的答案似乎并没有工作我怎么怀疑。所以我仍然在寻找一个答案!
Unfortunately the previously accepted answer does not seem to work how i suspected. So I'm still looking for an answer!
推荐答案
您可以使用的的变换而生成伪随机正态分布号码的顺序从0到1之间uniformally分布式数字序列
You can use the Box-Muller transform to generate a sequence of psuedorandom normally distributed numbers from a sequence of numbers uniformally distributed between 0 and 1.
这篇关于如何实现的随机数发生器,不是随机的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!