What are the possible ways to generate a random time series?

조회 수: 23 (최근 30일)
Andi
Andi 2022년 7월 5일
답변: Muskan 2023년 9월 5일
Hi everyone,
I require generating random times to test the computation. However, I got totally different results when I repeated my experiment for 1000 and, 10000 random time values. Here is the script that I used to generate random times.
NUMBER_RANDOM_TIMES = 10000;
SECONDS_PER_DAY = 24*60*60;
START_DATE = '2015-07-01';
END_DATE = '2021-12-31';
% Algorithm
startDateNum = datenum(START_DATE,'yyyy-mm-dd');
endDateNum = datenum(END_DATE, 'yyyy-mm-dd');
dayRange = endDateNum - startDateNum;
secondsRange = SECONDS_PER_DAY*dayRange;
randomNumberOfSeconds = randi(secondsRange,NUMBER_RANDOM_TIMES,1);
randomDatenums = startDateNum + randomNumberOfSeconds/SECONDS_PER_DAY;
AA = datevec(randomDatenums);
I think maybe the random times generated by this method are biased. May someone share their thoughts and suggest other possible ways to generate random time's bounded between the start and end dates.
Thank you!
  댓글 수: 1
Chunru
Chunru 2022년 7월 5일
There is no problem in the above random time generate. It is expected that the results (not sure what results are referred to) will be different with 1000 trials and 10000 trials. In theory, the results (some statistics ???) will be converging when number of trials are bit enough.

댓글을 달려면 로그인하십시오.

답변 (1개)

Muskan
Muskan 2023년 9월 5일
Hi Andi,
As per my understanding of the question when generating random numbers, the results can vary each time you run the experiment due to the nature of the random number generation algorithm.
The difference in results between 1000 and 10000 random time values could be due to the larger sample size in the latter case.
You can further refer to the following answer and documentation for a better understanding:
I hope the above information helps resolve your query.
Thanks

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by