how to generate true random number

4 ビュー (過去 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.
Walter Roberson
Walter Roberson 2017 年 6 月 9 日

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

回答 (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 件のコメント
Walter Roberson
Walter Roberson 2017 年 6 月 10 日
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 Center および File Exchange乱数発生器 についてさらに検索

Community Treasure Hunt

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

Start Hunting!