How can I generate random numbers
1 次查看(过去 30 天)
显示 更早的评论
I have along data series which contains 3451 elements. From this I want to select 1/3 rd of the elements for validation purpose and the remaining for test. How can I randomly make the selection randomly? Thanks .
0 个评论
采纳的回答
Image Analyst
2013-4-14
编辑:Image Analyst
2013-4-14
Use randperm(), as this demo illustrates:
% Define the number of elements to use.
numberOfElements = 3451;
oneThird = int32(floor(numberOfElements / 3));
% Get all the indexes scrambled in a random order.
randomOrder = int32(randperm(3451));
% Select a third of them for "Validation."
indexesForValidation = randomOrder(1:oneThird);
% Select the remainder of them for "testing."
indexesForTesting = randomOrder(oneThird+1:end);
4 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Random Number Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!