如何实现非均匀概率分布?

发布于 2024-09-06 18:23:56 字数 245 浏览 11 评论 0原文

我正在尝试在遗传算法中实现非均匀概率分布。

在遗传程序的实现中,我有一个实验,有3个结果,每个结果都有不同的概率。假设一种结果的概率是 0.85,另一种结果的概率是 0.01,最后一种结果的概率是 0.14?

PS:我最近才知道这叫概率非均匀分布。我正在用Java实现它,任何人都可以告诉非均匀概率背后的理论吗?分销及以及任何实现它的 Java 包。

如果您需要有关该问题的更多信息,请随时询问我!

提前致谢!

I am trying to implement non-uniform probability distribution in genetic algorithm.

In the implementation of genetic program, I have an experiment which has 3 outcomes, where each outcome has different probabilities. Let say, probablity of one outcome is 0.85, other is 0.01 and last one is 0.14?

P.S: i recently came to know that it is called non-uniform distribution of probability. I'm implementing it in Java, can anyone tell the theory behind non-uniform prob. distribution & also any Java packages implementing it.

Feel free to ask me know, if u need any more information on the problem!

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

守望孤独 2024-09-13 18:23:56

对于简单的离散分布,您可以编写一个采样器,它将使用累积概率以所需的频率返回结果。

Random r = new Random();
double v = r.nextDouble();

if (v <= 0.85) { return 0; }
if (v <= 0.86) { return 1; }
return 2;

这将以 0.85、0.01 和 0.14 的概率返回数字 0、1 和 2。

至于非均匀概率分布的理论,您可以从这篇关于概率分布;请特别注意页面底部的可折叠部分。您会发现有数十种具有不同属性的非均匀分布(连续和离散)。

For a simple discrete distribution, you can write a sampler that will return your outcomes with the desired frequency by using the cumulative probabilities.

Random r = new Random();
double v = r.nextDouble();

if (v <= 0.85) { return 0; }
if (v <= 0.86) { return 1; }
return 2;

This will return the numbers 0, 1 and 2 with a probability of 0.85, 0.01 and 0.14.

As far as the theory on non-uniform probability distributions, you can start with this Wikipedia article on probability distributions; take special note of the collapsible sections at the bottom of the page. You will find that there are dozens of non-uniform distribution (both continuous and discrete) with different properties.

梦里南柯 2024-09-13 18:23:56

在您的特定情况下,最好在 [0; 中获取随机值100) 使用均匀分布,然后检查它落在什么范围内:[0; 85), [85;99), [99, 100)

In your particular case it is better to get a random value in [0; 100) using uniform distribution and then check what range it falls in: [0; 85), [85;99), [99, 100)

独﹏钓一江月 2024-09-13 18:23:56

根据您的描述,在我看来您正在谈论健身比例选择(也称为轮盘赌选择)。
http://en.wikipedia.org/wiki/Roulette-wheel_selection

我认为nailxx ' 答案非常简洁地描述了您需要做什么。

参见
遗传算法中的轮盘赌选择
轮盘赌选择算法

如果我错了,这里有一些您可能会发现有用的库:< br>
http://www.ee.ucl.ac.uk/~ mflanaga/java/Stat.html
http://commons.apache。 org/math/apidocs/org/apache/commons/math/random/package-summary.html

Based on your description it seems to me that you are talking about fitness proportionate selection (also known as roulette wheel selection).
http://en.wikipedia.org/wiki/Roulette-wheel_selection

I think nailxx' answer is a pretty compact description what you need to do.

see also
Roulette Selection in Genetic Algorithms
Roulette wheel selection algorithm

If I'm wrong here are some libraries that you may find useful:
http://www.ee.ucl.ac.uk/~mflanaga/java/Stat.html
http://commons.apache.org/math/apidocs/org/apache/commons/math/random/package-summary.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文