how to generate true random number

조회 수: 3 (최근 30일)
hu wong
hu wong 2017년 6월 9일
댓글: David 2025년 1월 8일
Hi everyone: I am trying to generate true random number by MATLAB. I tried the intrinsic functions, 'randn'. But finally, I found it is not true random number generators. I generate 10000 random numbers, found the mean of them are not near 0, some cases the mean are 0.04,0.007 ....they are big. And the sum of the numbers is very big, 87, 73 130 ... So I believe that the function 'randn' is not a true random number generator. Does anyone know how to generate true random number by MATLAB?
  댓글 수: 2
Stephen23
Stephen23 2017년 6월 9일
편집: Stephen23 2017년 6월 9일
" I am trying to generate true random number by MATLAB"
This is a contradiction in terms: all computers (that MATLAB currently runs on) are deterministic.
Some ways to get "true random numbers":
  • Use radioactive decay
  • Use a service like https://www.random.org/, which apparently uses atmospheric noise.
  • Use diode breakdown noise.
  • Buy a book of random numbers.
Or simply accept that the algorithms used by MATLAB are as random as you will need for any modelling that you are doing.

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

답변 (2개)

David Goodmanson
David Goodmanson 2017년 6월 9일
편집: David Goodmanson 2017년 6월 9일
Hello, hu
yes, Matlab random numbers are not truly random, but they are a very good simulation. The results you are seeing would happen even for a set of truly random numbers. Suppose you take N samples from a given distribution with mean m and standard deviation s. By the central limit theorem, for large N those samples have a normal distribution with mean m and standard deviation s/sqrt(n). So you you should expect some variations from the official mean, even for perfectly random numbers. And those variations should be on the order of 1/sqrt(1e4) = .01.
  댓글 수: 3
David Goodmanson
David Goodmanson 2017년 6월 10일
Hello hu
It depends on what you mean by 'close to 0'. In a random walk model, for N steps you expect that the root mean square distance from the starting point will increase like sqrt(N). If the particle moved with constant velocity then the distance would increase like N. Compared to that, sqrt(N) is close to 0.
sqrt(N) behavior leads to diffusion. If you try to make random numbers with a sum that is artificially smaller than that, then you do not have the standard random walk.

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


Walter Roberson
Walter Roberson 2017년 6월 9일
  댓글 수: 2
David
David 2025년 1월 8일
Is it possible for MATLAB to tap the entropy source on x86 machines?
If not, it would be nice to add this functionality and have random numbers suitable for cryptography.
As a side note, I suspect that the Sigma-Delta ADC topology was a byproduct of developing similar entropy sources.

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

카테고리

Help CenterFile Exchange에서 乱数発生器에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!