熟记常见的置信区间的分位数
import numpy as np import scipy.integrate as integrate average_, standard_deviation = 0, 1 f = lambda x: (np.exp(-(x - average_) ** 2 / (2 * standard_deviation ** 2))) / ( np.sqrt(2 * np.pi)) / standard_deviation r = integrate.quad(f, -1.96, 1.96) x, step, l = 1, 0.01, [] for i in range(200): x += step r_ = integrate.quad(f, -x, x) l.append([x, r_[0], r_[1]]) l_6 = [] while r_[0] > 0.6: x -= step r_ = integrate.quad(f, -x, x) l_6.append([x, r_[0], r_[1]]) l_6 = sorted(l_6, reverse=False, key=lambda l: l[0]) n99, l_99 = float('{}{}'.format('0.', ''.join(['9' for i in range(9)]))), [] while r_[0] < n99: x += step r_ = integrate.quad(f, -x, x) l_99.append([x, r_[0], r_[1]]) l_99 = sorted(l_99, reverse=True) dd = 9
90% 1.65
<class 'list'>: [1.6400000000000006, 0.8989948330517928, 6.786100643460162e-14]
<class 'list'>: [1.6500000000000006, 0.9010570639327039, 8.072601275034688e-14]
95% 1.96
<class 'list'>: [1.9500000000000008, 0.9488238809567229, 9.078658007177475e-12]
<class 'list'>: [1.9600000000000009, 0.9500042097035593, 1.047408678736607e-11]
6个9 4.90
<class 'list'>: [4.889999999999939, 0.9999989916402233, 7.499501297747457e-10]
<class 'list'>: [4.899999999999939, 0.9999990416334469, 7.649097605311184e-10]
1.01 68.75%