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 .

 採用された回答

Image Analyst
Image Analyst 2013 年 4 月 14 日
編集済み: Image Analyst 2013 年 4 月 14 日

0 投票

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 件のコメント

Ede gerlderlands
Ede gerlderlands 2013 年 4 月 14 日
Thank you...
Ede gerlderlands
Ede gerlderlands 2013 年 4 月 14 日
Sorry I think Index for testing doesn't seems to work for me.
Image Analyst
Image Analyst 2013 年 4 月 14 日
編集済み: Image Analyst 2013 年 4 月 14 日
I fixed a small bug. Try it now.
Ede gerlderlands
Ede gerlderlands 2013 年 4 月 14 日
yes , it works tnx.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Random Number Generation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by