【发布时间】:2020-06-03 23:17:47
【问题描述】:
我正在编写一种在 python 中对样本应用统计引导的方法,我提供了两种解决方案,一种是完全矢量化的,另一种是使用列表理解的。
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
sample = np.array([80,75,91,97,88,77,94])
bs_sample_1 = np.random.choice(sample,size = (10000,7)).mean(axis = 1)
bs_sample_2 = np.array([np.random.choice(sample,size = 7).mean() for i in range(10000)])
plt.figure()
sns.distplot(sample)
plt.figure()
sns.distplot(bs_sample_1)
plt.figure()
sns.distplot(bs_sample_2)
我对 RNG 了解不多,但我不确定这两个操作是否同样有效地生成引导样本。
【问题讨论】:
标签: python machine-learning random statistics-bootstrap