Skip to Main Content
算法技术手册(原书第2 版)
book

算法技术手册(原书第2 版)

by George T.Heineman, Gary Pollice, Stanley Selkow
August 2017
Intermediate to advanced content levelIntermediate to advanced
360 pages
8h 35m
Chinese
China Machine Press
Content preview from 算法技术手册(原书第2 版)
316
11
首先必须能够从集合中随机选择出某些元素然后它们进行标记。由于假设集合是有限
规模的,因此在某个时间点上最后会发现随机选择函数返回了之前标记过的元素。这个
时间点拖得越长,那么数据规模就会越大。在统计学上,这叫作“重置抽样”。而根据
标记过的元素数量
k
,我们可以大概估计出
k
n
的关系,即
Example 11-6. Implementation of probabilistic counting algorithm
def computeK(generator):
"""
Compute estimate of using probabilistic counting algorithm.
Doesn't know value of n, the size of the population.
"""
seen = set()
while True:
item = generator()
if item in seen:
k = len(seen)
return 2.0*k*k/math.pi
else:
seen.add(item)
Let’s start with some intuition. We must have the ability to pick random elements
from the set and mark them as being seen. Since we assume the set is finite, at some
point ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

机器学习实战:基于Scikit-Learn、Keras 和TensorFlow (原书第2 版)

机器学习实战:基于Scikit-Learn、Keras 和TensorFlow (原书第2 版)

Aurélien Géron
Go语言编程

Go语言编程

威廉·肯尼迪
C++语言导学(原书第2版)

C++语言导学(原书第2版)

本贾尼 斯特劳斯特鲁普

Publisher Resources

ISBN: 9787111562221