概率数据结构 [英] Probabilistic Data Structure

查看:93
本文介绍了概率数据结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!,


有没有人知道网站的链接或知道创建数据的最佳方式

结构将挑选随机元素从本身分配了

概率?


例如,假设我创建了一个包含3个大理石(红色,绿色和蓝色)的包和

红色大理石被挑选的变化为50%,而绿色和蓝色大理石

都有25%的机会被挑选。它们应该是随机挑选的,但是这样选择的方式是红色大理石的选择时间是一半,而另外两个季度则是b $ b。什么是最好的方法呢?

算法?


谢谢,

David
或******* @ yahoo.com

Hi All!,

Does anyone know a link to a website or know the best way to create a data
structure that will pick random elements from itself with assigned
probabilities?

For example, say I created a bag of 3 marbles(red, green, and blue) and the
red marble had a 50% change of being picked while the green and blue marbles
both had 25% chance of being picked. they should be picked randomly, but
picked in such a way that the red marble will be picked half the time and
the other 2 a quarter of the time. What is the best way to do this
algorithmically?

Thanks,
David
or*******@yahoo.com


推荐答案

David Turner写道:
David Turner wrote:
大家好!,

有没有人知道网站的链接或知道创建的最佳方式一个数据结构,它将从自身中选择随机元素并指定
概率?

例如,假设我创建了一个包含3个大理石(红色,绿色和蓝色)的袋子,红色大理石的采摘变化了50%,而绿色和蓝色的大理石都有25%的被采摘机会。它们应该随机挑选,但选择的方式是红色大理石将被拣选一半时间,而另外两个时间将被拣选。什么是最好的方法来实现这个?
算法?
Hi All!,

Does anyone know a link to a website or know the best way to create a data
structure that will pick random elements from itself with assigned
probabilities?

For example, say I created a bag of 3 marbles(red, green, and blue) and the
red marble had a 50% change of being picked while the green and blue marbles
both had 25% chance of being picked. they should be picked randomly, but
picked in such a way that the red marble will be picked half the time and
the other 2 a quarter of the time. What is the best way to do this
algorithmically?




我会这样做,例如,创建一个
4个元素,0和1 =''红色'',2 =''绿色''和3 =''蓝色'',然后

随机选择元素0到3均匀。


SteveE



The way I would do it, for your example, would be to create an array of
4 elements, with 0 and 1 = ''red'', 2 = ''green'' and 3 = ''blue'', then
randomly select elements 0 to 3 evenly.

SteveE


David Turner写道:
David Turner wrote:
大家好! ,

有没有人知道一个网站链接或知道创建数据结构的最佳方法,该结构将从指定的
概率中挑选自己的随机元素?

例如,假设我创造了一个包含3个大理石(红色,绿色和蓝色)的袋子,并且
红色大理石在被绿色和蓝色大理石选择时有50%的变化
有25%的几率被选中。它们应该随机挑选,但选择的方式是红色大理石将被拣选一半时间,而另外两个时间将被拣选。什么是最好的方法呢?
算法?
谢谢,
大卫
或******* @ yahoo.com
Hi All!,

Does anyone know a link to a website or know the best way to create a data
structure that will pick random elements from itself with assigned
probabilities?

For example, say I created a bag of 3 marbles(red, green, and blue) and the
red marble had a 50% change of being picked while the green and blue marbles
both had 25% chance of being picked. they should be picked randomly, but
picked in such a way that the red marble will be picked half the time and
the other 2 a quarter of the time. What is the best way to do this
algorithmically?

Thanks,
David
or*******@yahoo.com




如果你只需要两个分区,你可能会能够使用二叉树烹饪某些东西





If you only need divisions of two, you might be able to cook up somthing
using a binary tree.


" David Turner" <或******* @ yahoo.com>在留言新闻中写道:< 7H ******************* @ news4.srv.hcvlny.cv.ne t> ...
"David Turner" <or*******@yahoo.com> wrote in message news:<7H*******************@news4.srv.hcvlny.cv.ne t>...
大家好!,

有没有人知道链接到网站或知道创建数据结构的最佳方法,该结构将从指定的
概率中挑选自己的随机元素?

例如,假设我创造了一个包含3个大理石(红色,绿色和蓝色)的袋子,并且
红色大理石在被绿色和蓝色大理石拣选时有50%的变化。两者都有25%的机会被选中。它们应该随机挑选,但选择的方式是红色大理石将被拣选一半时间,而另外两个时间将被拣选。什么是最好的方法呢?
算法?
谢谢,
大卫
或******* @ yahoo.com




嗨那里

u可以保持阵列具有各自概率的节点&一个

数组,用于维持节点被选择的次数,直到时间和时间为止。然后

生成一个随机数&检查是否有时间>没有时间它应该选择
然后生成另一个没有选择那个节点

这就是它

问候

amey



hi there
u can maintain array of nodes with their respective probabilities & an
array to maintain how many times the node was chosen till time & then
generate a random number & check if the no of times > no of times it
should have been chosen then generate another no else chose that node
this is it
regards
amey


这篇关于概率数据结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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