There are many cases where websites use random number generators to influence some sort of page behavior. One test to ensure the quality of a random number generator is to see if after many cases, the numbers produced follow a uniform distribution.
<!--more-->
Today, I will compare Internet Explorer 11, Chrome, and Firefox on a Windows 7 machine and report my results.
## Hypothesis
H0: The random numbers outputted follow the uniform distribution
HA: The random numbers outputted do not follow the uniform distribution
## Gathering Data
I wrote a small [website](http://share.zeropointshift.com/files/2017/03/random.html) and obtained my data by getting the CSV outputted when I use IE11, Firefox, and Chrome.
The website works by producing a random number using <codeclass='language-javascript'>Math.random()</code> between 1 and 1000 inclusive and calls the function 1,000,000 times. Storing it’s results in a file
This website produces a file with all the numbers separated by a comma. We want these commas to be replaced by newlines. To do so, we can run a simple command in the terminal
Do this with all three files and make sure to keep track of which is which.
Here are a copy of my files for [Firefox](https://brandonrozek.com/wp-content/uploads/2017/03/Firefox_corrected.csv), [Chrome](https://brandonrozek.com/wp-content/uploads/2017/03/Chrome_corrected-1.csv), and [IE11](https://brandonrozek.com/wp-content/uploads/2017/03/IE11_corrected.csv)
## Check Conditions
Since we’re interested in if the random values occur uniformly, we need to perform a Chi-Square test for Goodness of Fit. With every test comes some assumptions
<u>Counted Data Condition:</u> The data can be converted from quantatative to count data.
<u>Independence Assumption:</u> One random value does not affect another.
<u>Expected Cell Frequency Condition:</u> The expected counts are going to be 10000
Since all of the conditions are met, we can use the Chi-square test of Goodness of Fit
## Descriptive Statistics
For the rest of the article, we will use R for analysis. Looking at the histograms for the three browsers below. The random numbers all appear to occur uniformly
At a 5% significance level, we fail to obtain enough evidence to suggest that the distribution of random number is not uniform. This is a good thing since it shows us that our random number generators give all numbers an equal chance of being represented. We can use `Math.random()` with ease of mind.