0
$\begingroup$

Lets say there's a function that produces a random number between 1-10000. We need to verify that the generated numbers are truly random and that the distribution is uniform.

  • How do we test the randomness?
  • How many numbers we need to know that the results are statistically significant?
$\endgroup$
0

1 Answer 1

1
$\begingroup$

The first thing you should do is to plot your data and visually compare it against the intended distribution.

in R you could do:

plot(density(runif(100000,min=1,max=10000)), col="red") #random data from uniform distribution
lines(density(myData)) # your data

If the plot looks reasonably similar, you could perform a kolmogorov smirnov test to obtain a p-value for the uniformity of your distribution:

ks.test(myData, "punif", min=1,max=10000)

The null hypothesis is that your data is drawn from a uniform distribution. I.e. you want this test to be NOT significant.

If this is not enough and you want to test true "randomness", the area gets more complex. I'm no expert, but for sure I know that there are at least various definitions of randomness, and you most probably would have to refine your question, to have a better answer.

Anyway you could take a look into R's randtest package, to find inspiration!

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.