split dataset with probability weights
显示 更早的评论
Hello everyone
i have a dataset like 20 x 6. i want to split dataset (npop1) into two dataset which depend on probabbility 'weights'. the probability comes from random number r1. i can't figure out how to store the rest data into another variable dataset (rw2). I don't use randperm because randperm has no probability function. I will appreciate any help. Thank you.
Sorry for my bad English..
pc = 0.4; %percentage to split data
nfitA = length(fitA);
PC = pc*npop;% make positive interger
r1 = rand (nfitA,1); %random number for weight probability
rw1 = datasample(npop1,PC,'Weights',r1);
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Multinomial Distribution 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!