Skip to content
Prev 371275 / 398530 Next

Optimize code to read text-file with digits

Simplest version that I can think of:

x <- scan("~/Downloads/digits.txt")
x <- x[-seq(1,220000,11)]
length(x) # 200000
hist(x)

Now, because it's Friday: 

How does one work out the theoretical distribution of the following table?
0     1     2     3     4     5     6     7     8     9    10    11 
13497 27113 27010 18116  9122  3466  1186   366    99    22     1     1 
   12 
    1 

(I.e., out of 200000 random 5 digit numbers, 13497 numbers never occurred, 27113 numbers exactly once, and ... and 1 number occurred 12 times.)

-pd