random number generator test

后端 未结 4 1684
太阳男子
太阳男子 2021-01-03 00:42

How will you test if the random number generator is generating actual random numbers?

My Approach: Firstly build a hash of size M, where M is the prime number. Then

4条回答
  •  无人及你
    2021-01-03 01:23

    I had the same problem. when I finish to write my code (using an external RNG engine)

    I looked on the results and found that all of them fail Chi-Square test whenever I have to many results.

    my code generated a random number and hold buckets of the amount of each result range. I don't know why the Chi-square test fail when i have a lot of results.

    during my research I saw that the C# Random.next() fail in any range of random and that some of the numbers have better odds than the other, further more i saw that the RNGCryptoServiceProvider random provider is not supporting good on big numbers.

    when trying to get numbers in the range of 0-1,000,000,000 the numbers in the lower range 0-300M have better odds to appear...

    as a result I'm using the RNGCryptoServiceProvider and if my range is higher than 100M i'm combine the number my self (RandomHigh*100M + RandomLow) and the ranges of both randoms is smaller than 100M so it good.

    Good Luck!

提交回复
热议问题