I'm coding my university assignment that is somewhat connected with distributions and random roll stuff. So the question is: how to get a random number with a given discrete distribution in Ruby.
To be more specific: in trivial example with normal discrete distribution like (0 with P=1/2; 1000 with P=1/2) I could write such a function:
def chooseNumber(a,b)
rval = Random.rand(0..1)
return a if rval == 0
return b
end
Run Code Online (Sandbox Code Playgroud)
First question: is there any way to write it using …
我试图在遗传算法中实现非均匀概率分布.
在遗传程序的实施中,我有一个实验,其中有3个结果,每个结果都有不同的概率.比方说,一个结果的可能性是0.85,另一个是0.01,最后一个是0.14?
PS:我最近才知道它被称为概率的非均匀分布.我用Java实现它,任何人都能说出非均匀概率背后的理论.分发以及实现它的任何Java包.
如果您需要有关此问题的更多信息,请随时向我询问!
提前致谢!
probability genetic-programming probability-theory genetic-algorithm