def bootstrap_ts(y, func, B=<NUM_LIT:1000>, b=<NUM_LIT:3>):
beta_star = np.empty(B)<EOL>z = y<EOL>z_star = np.empty(len(z))<EOL>for boot_i in range(B):<EOL><INDENT>for block_i, start in enumerate(np.random.randint(len(z) - b + <NUM_LIT:1>, size=len(z) / b)):<EOL><INDENT>z_star[block_i * b:(block_i + <NUM_LIT:1>) * b] = z[start:start + b]<EOL>beta_star[boot_i] = func(z_star)<EOL><DEDENT><DEDENT>return beta_star<EOL>
Bootstrap a timeseries using a window size:b.