Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8462837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:17:07+00:00 2026-06-10T14:17:07+00:00

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

  • 0

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 take the number
generated by random number generator, and take mod with M.
and see it fills in all the hash or just in some part.
That’s my approach. Can we prove it with visualization?

Since I have very less knowledge about testing. Can you suggest me a thorough approach of this question? Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:17:09+00:00Added an answer on June 10, 2026 at 2:17 pm

    You should be aware that you cannot guarantee the random number generator is working properly. Note that even a perfect uniform distribution in range [1,10] – there is a 10-10 chance of getting 10 times 10 in a random sampling of 10 numbers.

    Is it likely? Of course not.

    So – what can we do?

    We can statistically prove that the combination (10,10,….,10) is unlikely if the random number generator is indeed uniformly distributed. This concept is called Hypothesis testing. With this approach we can say "with certainty level of x% – we can reject the hypothesis that the data is taken from a uniform distribution".

    A common way to do it, is using Pearson’s Chi-Squared test, The idea is similar to yours – you fill in a table – check what is the observed (generated) number of numbers for each cell, and what is the expected number of numbers for each cell under the null hypothesis (in your case, the expected is k/M – where M is the range’s size, and k is the total number of numbers taken).

    You then do some manipulation on the data (see the wikipedia article for more info what this manipulation is exactly) – and get a number (the test statistic). You then check if this number is likely to be taken from a Chi-Square Distribution. If it is – you cannot reject the null hypothesis, if it is not – you can be certain with x% certainty that the data is not taken from a uniform random generator.

    EDIT: example:

    You have a cube, and you want to check if it is "fair" (uniformly distributed in [1,6]). Throw it 200 times (for example) and create the following table:

    number:                1       2         3         4          5          6
    empirical occurances: 37       41        30        27         32         33
    expected occurances: 33.3      33.3      33.3      33.3       33.3       33.3
    

    Now, according to Pearson’s test, the statistic is:

    X = ((37-33.3)^2)/33.3 + ((41-33.3)^2)/33.3 + ... + ((33-33.3)^2)/33.3 
    X = (18.49 + 59.29 + 10.89 + 39.69 + 1.69 + 0.09) / 33.3
    X = 3.9
    

    For a random C~ChiSquare(5), the probability of being higher then 3.9 is ~0.45 (which is not improbable)1.

    So we cannot reject the null hypothesis, and we can conclude that the data is probably uniformly distributed in [1,6]


    (1) We usually reject the null hypothesis if the value is smaller then 0.05, but this is very case dependent.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a function that will generate 2 random numbers between x
I need to perform few tests where I use randn pseudo random number generator.
I am using MTRand (the Mersenne Twister random number generator from http://www.bedaux.net/mtrand/ ) inside
Will test results with 1000 users be similar to those I get with 10,000
I need a script that will test an input field's contents to see if
I'm trying to create a JQuery function that will test a string for the
So I know in ruby that x.nil? will test if x is null. What
screen -R -D -S test will create a session named test if it doesn't
I have a piece of NSString that will read Test & Test or with
<div style=background-color:black> <div style=float:right> Test message </div> <div> This will show 'Test message' with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.