【发布时间】:2015-03-10 22:45:17
【问题描述】:
这个问题有两个方面。首先,据我了解,从给定列表中统一删除 10% 的想法如下所示。 (1): 计算 10% * totul 元素个数 (2):随机均匀地一个一个移除元素,直到列表中的元素个数最多为90%*totul元素个数 即,
while (the current number of elements is bigger than 90% * totul number of elements)
randomly and uniformly generate an element from the current list and remove it.
上面说的对吗?这听起来更像没有替换吗?或者我可以使用任何内置的python函数。 其次,点击这个链接,Very fast sampling from a set with fixed number of elements in python 我的想法是从 python 的列表中删除元素是昂贵的。那么,有没有更好的方法来解决这个问题?非常感谢。
【问题讨论】:
-
统一是什么意思?
-
表示每个元素被选中的概率相同。
标签: python