oversampling an array randomly
    3 次查看(过去 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 中查找有关 Detection 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

