print("====percentile====")
X = np.random.randn(1) # random 1D array
N = 10 # number of bootstrap samples
print(X.size)
idx = np.random.randint(0, X.size, (N, X.size))
print("====means====")
print(X)
print(idx)
print(X[idx])
print(X.shape, idx.shape, X[idx].shape)
means = X[idx].mean(axis=1)
print(means.shape)
confint = np.percentile(means, [2.5, 97.5])
print(confint)
- e.g.
====percentile====
1
====means====
[ 0.41599196]
[[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]]
[[ 0.41599196]
[ 0.41599196]
[ 0.41599196]
[ 0.41599196]
[ 0.41599196]
[ 0.41599196]
[ 0.41599196]
[ 0.41599196]
[ 0.41599196]
[ 0.41599196]]
((1,), (10, 1), (10, 1))
(10,)
[0.41599196248944836, 0.41599196248944836]