Random Integers of Specified Number of Digits
Create n random integer valued numbers all with a specified number of
digits d.
randI(n, d)
n |
numeric sample size, i.e., |
d |
a positive integer, giving the exact number of digits the resulting numbers must have. |
10^(d-1) <= N[i] < 10^d,
and every N[i] appears with the same probability 1 / (9*10^(d-1))
Martin Maechler
plot(
T2 <- table(randI(1e6, 2))) ; abline(h = 1e6 / (9*10^(2 - 1)), lty=2, col="gray70")
chisq.test(T2) # typically not at all significant
T3 <- table(randI(1e6, 3))
chisq.test(T3)
stopifnot(exprs = {
identical( 10:99 , as.integer(names(T2)))
identical(100:999, as.integer(names(T3)))
})Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.