查看以下两点,然后思考:对您而言,哪一项似乎更“随机”?左图中的分布明显不均匀。在某些地方会压缩点,在有些地方也几乎没有点:因此,左侧图表甚至看起来更暗。在右图中,也存在局部凝结和稀疏现象,但它们不那么明显。
![](https://habrastorage.org/webt/sx/r2/ks/sxr2ks7jjoyc52bev0bh-pbs4ss.png)
同时,它是使用“诚实”随机数生成器获得的左图。右图还包含完全随机的点;但是会生成这些点,以便所有小方块都包含相同数量的点。
分层是从总体中选择对象子集(分为子集(层))的一种方法。在分层过程中,选择对象的方式应使最终样本保留分层大小的比率(或以受控方式违反这些关系,请参见第3节)。假设在所考虑的示例中,总人口是单位正方形内的点;地层是较小正方形内的点集。
. , . , - .
1. :
![](https://habrastorage.org/webt/im/hc/vi/imhcvikbqqz6pknwuhyhdttdzu4.png)
, , — , 0.4. . -.
![](https://habrastorage.org/webt/fa/gd/2o/fagd2oblunypcy_uglwon59_xsw.png)
() :
import random
random.seed(100)
for i in range(500):
x, y = random.random(), random.random()
print x, y
, : , ; . , , , .
import random
random.seed(100)
cellsCount = 10
cellId = 0
for i in range(500):
cellVerticalIdx = (cellId / cellsCount) % cellsCount
cellHorizontalIdx = cellId % cellsCount
cellId += 1
left = float(cellVerticalIdx + 0) / cellsCount
right = float(cellVerticalIdx + 1) / cellsCount
top = float(cellHorizontalIdx + 1) / cellsCount
bottom = float(cellHorizontalIdx + 0) / cellsCount
x, y = random.random(), random.random()
x = left + x * (right - left)
y = bottom + y * (top - bottom)
print x, y
— . , — .
![](https://habrastorage.org/webt/fa/k2/hi/fak2hiyahreuja-vnxb45igulgg.png)
, , , .
, . ! , , , .
2. -
.
: , . , , . , .
: , .. . , , . , . , , — .
. :
![](https://habrastorage.org/webt/dn/i9/cs/dni9csdsey9dzt8jb7jaij4qnfu.png)
. , . , «» , , . , , !
, , -, .. , . ( ), :
![](https://habrastorage.org/webt/s4/dm/yg/s4dmygmplkmt3x-oxwxlbw0ebsq.png)
, , , . , , , , .
3.
-, -: , , , . A/B- , , , 0.5% , .
( , , ..), , .
Online Stratified Sampling: Evaluating Classifiers at Web-Scale Microsoft Research, .
, , .
— . - .
:
, !
, - :
, . , .
, : . , - , , .
![](https://habrastorage.org/webt/bg/da/tv/bgdatve6qhycl68qpnfwz6st4oq.jpeg)
, , . - SimilarWeb Alexa - , . , . , , .
: ? ? ?
如果没有答案或答案不令人满意,很可能是数据会欺骗您。