oversampling an array randomly
조회 수: 17 (최근 30일)
이전 댓글 표시
I have an array that contains 300 observations, and i would like to oversample this array to 472 observation. but i would this to be done randomly (randomly pick 172 observations and duplicate them). I've been looking online but with no luck
댓글 수: 0
채택된 답변
Chunru
2021년 9월 1일
a = randn(300, 1); % original data
idx = randperm(300, 172); % randomly pick 172 from 300
a1 = [a; a(idx)];
whos
댓글 수: 2
Chunru
2021년 9월 1일
If you want to ensure that original 300 are always included and addtional 471 are randomly sampled, you can do the following:
a = randn(300, 1); % original data
idx = randi([1 300], [471 1]); % 471 random numbers btw 1 and 300
a1 = [a; a(idx)];
whos
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!