What limitations does MATLAB have in pseudo-random sequence generation ?
2 views (last 30 days)
Show older comments
I am interested in learning about the limitations of the pseudo-random sequences generated by function rand() in terms of statistical independence.
For example if I work with the default rng settings (i.e. Type: 'twister', Seed: 0, State: [625x1 uint32]) and keep calling the function rand(1,1e5) multiple times, will the results eventually repeat ? If yes, then how many function calls are safe to get independent results? Or will the rng change its seed or type automatically to avoid repetitive results?
In the documentation link below it is said that the generated numbers "pass various statistical tests of randomness and independence". I would be very interested in seeing the detailed results of the tests, if possible.
https://www.mathworks.com/help/matlab/math/create-arrays-of-random-numbers.html
0 Comments
Accepted Answer
Bruno Luong
on 31 Oct 2022
According to this page, the period of Mersenne Twister (64 bit version, the default engine used by rand()) method is 2^19937-1
4 Comments
Steven Lord
on 1 Nov 2022
If you were to generate a billion pseudorandom numbers per second, how long would it take you to generate 2^19000 numbers?
totalSeconds = vpa(sym(2)^19000)/1e9
secondsPerYear = seconds(years(1));
totalNumberOfYears = vpa(totalSeconds/secondsPerYear)
So I wouldn't worry.
John D'Errico
on 1 Nov 2022
Instead of total number of years, you might have expressed that as the number of lifetimes of the universe before seeing a repeat. Of course our computers will all be long since turned into dust by then. And even the dust will have been sucked into black holes.
More Answers (0)
See Also
Categories
Find more on Random Number Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!