Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose you observe the sequence:

7, 9, 0, 5, 5, 5, 4, 8, 0, 6, 9, 5, 3, 8, 7, 8, 5, 4, 0, 0, 6, 6, 4, 5 , 3, 3, 7, 5, 9, 8, 1, 8, 6, 2, 8, 4, 6, 4, 1, 9, 9, 0, 5, 2, 2, 0, 4, 5, 2, 8 ...

What statistically tests would you apply to determine if this is truly random? FYI these are the $n$th digits of $\pi$. Thus, are digits of $\pi$ statistically random? Does this say anything about the constant $\pi$?

enter image description here

share|improve this question
-->… – ocram Nov 26 '12 at 17:24
Another one: Refutation of claims such as ``Pi is less random than we thought'' – user10525 Nov 26 '12 at 17:35
This is an interesting and maddening question. Any student that has taken a first course in measure-theoretic probability can easily prove that "almost all" real numbers are normal. But very few explicit examples are known, and to my (off-hand) knowledge, the matter has not been settled either way for any of the "famous" irrational mathematical constants. – cardinal Nov 26 '12 at 17:45
In (strict) connection with @cardinal's comment: Normal number – user10525 Nov 26 '12 at 17:52
What's the graph? There are ten bars, oddly spaced, and all with values above 10%! – xan Nov 29 '12 at 22:53
up vote 9 down vote accepted

The US National Institute of Standard has put together a battery of tests that a (pseudo-)random number generator must pass to be considered adequate, see There are also tests known as the Diehard suite of tests, which overlap somewhat with NIST tests. Developers of Stata statistical package report their Diehard results as a part of their certification process. I imagine you can take blocks of digits of $\pi$, say in groups of consecutive 15 digits, to be comparable to the double type accuracy, and run these batteries of tests on thus obtained numbers.

share|improve this answer

Answering just the first of your questions: "What tests would you apply to determine if this [sequence] is truly random?"

How about treating it as a time-series, and checking for auto-correlations? Here is some R code. First some test data (first 1000 digits):


Check the counts of each digit:

> table(digits)
  0   1   2   3   4   5   6   7   8   9 
 93 116 103 102  93  97  94  95 101 106 

Then turn it into a time-series, and run the Box-Pierce test:

d=as.ts( digits )

which tells me:

X-squared = 1.2449, df = 1, p-value = 0.2645

Typically you'd want the p-value to be under 0.05 to say there are auto-correlations.

Run acf(d) to see the auto-correlations. I've not included an image here as it is a dull chart, though it is curious that the biggest lags are at 11 and 22. Run acf(d,lag.max=40) to show that there is no peak at lag=33, and that it was just coincidence!

P.S. We could compare how well those 1000 digits of pi did, by doing the same tests on real random numbers.


This generates 1000 random digits, does the test, and repeats this 100 times.

> summary(probs)
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
0.006725 0.226800 0.469300 0.467100 0.709900 0.969900 
> sd(probs)
[1] 0.2904346

So our result was comfortably within the first standard deviation, and pi quacks like a random duck. (I used set.seed(1) if you want to reproduce those exact numbers.)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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