필터 지우기
필터 지우기

How can I generate random numbers

조회 수: 1 (최근 30일)
Ede gerlderlands
Ede gerlderlands 2013년 4월 14일
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일
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
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개)

카테고리

Help CenterFile Exchange에서 Hypothesis Tests에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by