How to perform block boostrap resampling with MATLAB?
조회 수: 9 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2020년 11월 24일
답변: MathWorks Support Team
2020년 11월 24일
I have time series data that I would like to use block bootstrapping to resample and expand my data set.
Is there a function in MATLAB that can do this?
채택된 답변
MathWorks Support Team
2020년 11월 24일
Below is an example of how to use "bootstrp" from the "Statistics and Machine Learning Toolbox" to perform non-overlapping block resampling on a MATLAB array:
ts = ["A","B","C","D"]
blockSize = 2;
numBlocks = length(ts) / blockSize; % must be integer
blocks = reshape(ts, [numBlocks,blockSize])' % reshape into non-overlapping blocks
nSamples = 10;
samples = bootstrp(nSamples, @(x)x', blocks) % @(x)x' maintains the sequence of items in the block
Running the code above will demonstrate that the "samples" output contains randomly sampled permutations of the rows in "blocks". In this case the blocks are "AB" and "CD", for ease of demonstration.
The main limitation of this approach is that the number of data points in the time series must be evenly divisible by the block size or "reshape" will throw an error.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Filter Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!