Ain't working, doesn't exist in numpy
as fun (or joke), to check stationary bootstrap on the command line
1000 draws of the index for stationary bootstrap with mean block
length equal to 4, as a one-liner:
(uses large oversampling to guarantee minimum size is nobs)
>>> nobs = 10
>>> ridx = np.array([(np.concatenate([np.arange(start, start+length) for start, length in zip(np.random.randint(nobs, size=nobs), np.random.geometric(1./4, size=nobs))])[:nobs]) for _ in xrange(1000)])
>>> ridx[ridx>=nobs] = ridx[ridx>=nobs] - nobs
>>> for i in range(5): print ridx[i]
[1 2 9 0 1 2 3 8 9 0]
[2 8 9 0 6 7 8 9 1 6]
[1 2 3 4 5 6 7 7 8 7]
[4 5 6 7 3 4 5 6 2 3]
[1 3 4 5 8 1 2 3 4 5]
>>> np.bincount(ridx.ravel())
array([1011, 989, 1019, 1017, 992, 983, 994, 1008, 980, 1007])
another run
array([1018, 979, 972, 1023, 1005, 1018, 993, 983, 1015, 994])
looks roughly uniform
but is not "production" code
Josef
>
> Josef
>
>>
>> Josef
>>
>>> A.