小数に強いはずの bootstrap test を試す

真値 0 を持ち,分散 1 で観測される x という変数を 5 回観測したとする.その5回の観測量から,元の分布関数の特長を調べたいので bootstrap する.

import numpy
import pylab
n = 5
trial = 1000
a=numpy.random.normal(0,1,n)
b=numpy.array([a[map(lambda x: int(x), numpy.random.rand(n)*n)].std() for i in range(trial) ])
pylab.hist(b)
pylab.show()

観測値 vector が a で b が bootstrap 的に実現した vector の列.

>>> a.std()
0.82869230791556148
>>> b.std()
0.2586508738464719
>>> b.mean()
0.69612006856055253

観測値の標準偏差は 0.83で,その誤差が 0.26 程度とって,もとの統計関数の標準偏差 1.00 と誤差の範囲で一致する.