Bootstrap a timeseries using a window size:b.

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