forgot that
This commit is contained in:
parent
8c1be4a885
commit
0c735905f1
14
presentation/spin_chain/bootstrap.py
Normal file
14
presentation/spin_chain/bootstrap.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
import numpy as np
|
||||
from collections import Counter, deque
|
||||
|
||||
def bootstrap(m, nsample, resample_len, nresamples, f):
|
||||
whole_sample = np.zeros(nsample)
|
||||
whole_sample[m:] = 1
|
||||
|
||||
results = deque()
|
||||
for _ in range(nresamples):
|
||||
sample = np.random.choice(whole_sample, resample_len)
|
||||
results.append(f(sample))
|
||||
|
||||
results = np.array(results).astype(np.double)
|
||||
return np.std(results)
|
Loading…
Reference in New Issue
Block a user