查看以下两点,然后思考:对您而言,哪一项似乎更“随机”?左图中的分布明显不均匀。在某些地方会压缩点,在有些地方也几乎没有点:因此,左侧图表甚至看起来更暗。在右图中,也存在局部凝结和稀疏现象,但它们不那么明显。

同时,它是使用“诚实”随机数生成器获得的左图。右图还包含完全随机的点;但是会生成这些点,以便所有小方块都包含相同数量的点。
分层是从总体中选择对象子集(分为子集(层))的一种方法。在分层过程中,选择对象的方式应使最终样本保留分层大小的比率(或以受控方式违反这些关系,请参见第3节)。假设在所考虑的示例中,总人口是单位正方形内的点;地层是较小正方形内的点集。
. , . , - .
1. :

, , — , 0.4. . -.

() :
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
— . , — .

, , , .
, . ! , , , .
2. -
.
: , . , , . , .
: , .. . , , . , . , , — .
. :

. , . , «» , , . , , !
, , -, .. , . ( ), :

, , , . , , , , .
3.
-, -: , , , . A/B- , , , 0.5% , .
( , , ..), , .
Online Stratified Sampling: Evaluating Classifiers at Web-Scale Microsoft Research, .
, , .
— . - .
:
, !
, - :
, . , .
, : . , - , , .

, , . - SimilarWeb Alexa - , . , . , , .
: ? ? ?
如果没有答案或答案不令人满意,很可能是数据会欺骗您。