Skip to content

Commit 0081ffd

Browse files
type hints
1 parent 1e1b73a commit 0081ffd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

StationaryBootstrap.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import numpy as np
22

3-
def StationaryBootstrap(data: np.ndarray, m, sampleLength)-> np.ndarray:
3+
def StationaryBootstrap(data: np.ndarray, m: float, sampleLength: int)-> np.ndarray:
44
"""
55
Returns a bootstraped sample of the time-series "data" of length "sampleLength.
66
The algorithm used is stationary bootstrap from 1994 Politis & Romano.
@@ -37,12 +37,12 @@ def StationaryBootstrap(data: np.ndarray, m, sampleLength)-> np.ndarray:
3737
Association, 89:428, 1303-1313, DOI: 10.1080/01621459.1994.10476870
3838
3939
Implemented by Gregor Fabjan from Qnity Consultants on 12/11/2021.
40+
4041
"""
41-
4242
accept = 1/m
4343
lenData = data.shape[0]
4444

45-
sampleIndex = np.random.randint(0,high =lenData,size=1);
45+
sampleIndex = np.random.randint(0,high =lenData,size=1)
4646
sample = np.zeros((sampleLength,1))
4747
for iSample in range(sampleLength):
4848
if np.random.uniform(0,1,1)>=accept:
@@ -53,4 +53,4 @@ def StationaryBootstrap(data: np.ndarray, m, sampleLength)-> np.ndarray:
5353
sampleIndex = np.random.randint(0,high = lenData,size=1)
5454

5555
sample[iSample,0] = data[sampleIndex]
56-
return sample
56+
return sample

0 commit comments

Comments
 (0)