随意偏见? [英] Biased random?

查看:65
本文介绍了随意偏见?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个项目列表,需要从中选择几个元素,

几乎随机。问题是从一开始元素

应该比最后的那些元素更有可能被选中(怎么样?
更多?我不在乎如何概率的包络看起来像

这一点 - 可以是线性的。我看到

Python标准库中有几个函数用于各种发行,但是有一种简单的方法可以让他们做我需要的吗?


-----开始PGP SIGNATURE -----

版本:GnuPG v1.2.5(MingW32)

评论:使用GnuPG使用Mozilla - http://enigmail.mozdev.org


iD8DBQFG0zdFldnAQVacBcgRAg / yAJ9ZVWfDptl4Qxl + kSIpZqoi00qNYgCg + YNf

jVEXRG + grsbVDrRH1wXSw14 =

= mGlJ

----- END PGP SIGNATURE- ----

Hi,

I have a list of items, and need to choose several elements from it,
"almost random". The catch is that the elements from the beginning
should have more chance of being selected than those at the end (how
much more? I don''t care how the "envelope" of probability looks like at
this point - can be linear). I see that there are several functions in
Python standard libraries for various distribution, but is there an easy
pythonic way to make them do what I need?

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG0zdFldnAQVacBcgRAg/yAJ9ZVWfDptl4Qxl+kSIpZqoi00qNYgCg+YNf
jVEXRG+grsbVDrRH1wXSw14=
=mGlJ
-----END PGP SIGNATURE-----

推荐答案

如何用附加值装饰你的元素列表,

哪个表示该元素的重量。值为1表示

''与任何其他''一样可能,< 1'将''不太可能比''任何其他和
How about decorating your list of elements with an additional value,
which indicates the weight of that element. A value of 1 will indicate
''as likely as any other'', < 1 will be ''less likely than'' any other and

1'将比其他任何'更可能''。然后根据权重和random()的输出的组合值创建一个排序列表
1 will be ''more likely than any other''. Then create a sorted list



;来自

这需要前N个元素来满足您的要求。


hth


Jon



8月27日21:42,Ivan Voras< ivoras @__ fer.hr__写道:

based on the combined value of weight and the output of random(); from
this take the first N many elements to meet your requirements.

hth

Jon


On 27 Aug, 21:42, Ivan Voras <ivoras@__fer.hr__wrote:





我有一个项目列表,需要从中选择几个元素,

几乎随机。问题是从一开始元素

应该比最后的那些元素更有可能被选中(怎么样?
更多?我不在乎如何概率的包络看起来像

这一点 - 可以是线性的。我看到

Python标准库中有几个函数用于各种发行,但是有一种简单的方法可以让他们做我需要的吗?


signature.asc

1K下载
Hi,

I have a list of items, and need to choose several elements from it,
"almost random". The catch is that the elements from the beginning
should have more chance of being selected than those at the end (how
much more? I don''t care how the "envelope" of probability looks like at
this point - can be linear). I see that there are several functions in
Python standard libraries for various distribution, but is there an easy
pythonic way to make them do what I need?

signature.asc
1KDownload



Ivan Voras写道:
Ivan Voras wrote:




我有一个项目列表,需要从中选择几个元素,

几乎是随机的。问题是从一开始元素

应该比最后的那些元素更有可能被选中(怎么样?
更多?我不在乎如何概率的包络看起来像

这一点 - 可以是线性的。我看到

Python标准库中有几个函数用于各种发行,但是有一种简单的方法可以让他们做我需要的吗?

Hi,

I have a list of items, and need to choose several elements from it,
"almost random". The catch is that the elements from the beginning
should have more chance of being selected than those at the end (how
much more? I don''t care how the "envelope" of probability looks like at
this point - can be linear). I see that there are several functions in
Python standard libraries for various distribution, but is there an easy
pythonic way to make them do what I need?



这很奇怪。对于大多数情况,random.randint(a,b)就足够了。测试

您的系统看到分布是否统一,例如:


----

导入随机

dist = {}
$ x $ b for x in xrange(100000):

u = random.randint(1,10)

尝试:

dist [u] = dist [u] + 1

除了KeyError:

dist [u] = 1


print dist

----

That''s weird. random.randint(a,b) will be enough for most cases. Test
your system to see the distribution is uniform with something like:

----
import random

dist = {}
for z in xrange(100000):
u = random.randint(1,10)
try:
dist[u] = dist[u] + 1
except KeyError:
dist[u] = 1

print dist
----


2007-08-27,Jun- geun Park< ju ********** @ gmail.comwrote:
On 2007-08-27, Jun-geun Park <ju**********@gmail.comwrote:

>我有一个清单项目,并需要从中选择几个元素,几乎随机。问题在于,一开始的元素应该比最终的元素更有可能被选中(还有多少?我不在乎
信封是什么?概率看起来像这一点 - 可以是线性的。我看到Python中有几个函数用于各种分发的标准库,但是有一种简单的pythonic方法可以让它们做我需要的吗?
>I have a list of items, and need to choose several elements
from it, "almost random". The catch is that the elements from
the beginning should have more chance of being selected than
those at the end (how much more? I don''t care how the
"envelope" of probability looks like at this point - can be
linear). I see that there are several functions in Python
standard libraries for various distribution, but is there an
easy pythonic way to make them do what I need?


这很奇怪。 random.randint(a,b)足以支付大多数b / b
的案例。测试你的系统看看发行是否统一

类似于:
That''s weird. random.randint(a,b) will be enough for most
cases. Test your system to see the distribution is uniform
with something like:



除了他想要一个非均匀分布。


-

格兰特爱德华兹格兰特哇!我正在更换CHANNEL的

...但我得到的全部

visi.com是RONCO的商业广告

MIRACLE BAMBOO STEAMERS!

Except he wants a non-uniform distribution.

--
Grant Edwards grante Yow! I''m changing the
at CHANNEL ... But all I get
visi.com is commercials for "RONCO
MIRACLE BAMBOO STEAMERS"!


这篇关于随意偏见?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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