Random or non random

1.6k Views Asked by At

If I have a function $F(x)$, and the range of answers $F$ can provide is $1, 2$ or $3,$ is the output produced by $F$ "random"?

The computer science professor's response: No, it is not random, because the output MUST be $1, 2$ or $3$ and cannot be anything else. It can never be $4,$ so it is not random because you have knowledge of what the output must be.

The math professor's response: Yes, it is random because even if you limit the range of possible answers, you don't know which answer it will be.

So the core question seems to be if something is "random" if you can restrict it down to certain possibilities?

1

There are 1 best solutions below

1
On BEST ANSWER

Without getting into a useless 'war' between math and CS, let me try to sort out the usual terminology. At best, the question seems to be dealing with reports of informal comments made by faculty members.

In statistics and probability modeling, it is certainly possible to have a random sample from a small discrete population. Usually that means that each population element has an equal chance of being chosen and that choices are made independently. In your example the population is $\{1, 2, 3\}$ and in rolling a fair die, as in @Bungo's comment, the population is ${1,2,3,4,5,6}.$

Other random variables can produce (in theory at least) continuous values. An example is the distribution $\mathsf{Norm}(0,1),$ which can take any value on the real line, but concentrates about 95% of its output to the interval $(-2,2).$ It is not possible to have a random variable that puts equal probability on each of the real numbers. [In practical applications, one must round the continuous values to some number of decimal places, so that results become 'discrete' rational numbers, and tied values may occasionally occur.]

In computer simulation, most models are built on numbers that are (or are essentially indistinguishable from) realizations of a random variable $U$ with the distribution $\mathsf{Unif}(0,1).$ Traditionally, computer applications have used deterministic algorithms (e.g., the 'Mersenne Twister') that are carefully chosen to produce values that cannot be distinguished from a random sample from $\mathsf{Unif}(0,1),$ using many different statistical tests of randomness (see Marsaglia's 'Die Hard' battery of tests). These are called 'pseudo-random' values; if not truly random they are relentlessly unpredictable. More recently, as in @Bungo's link to Intel, some processors have tapped 'high-entropy pools' to obtain numbers from sources thought, on the basis of physical theories, to be truly random. Perhaps quantum computing will provide new sources of random numbers.

Everything else is built up from random values $U \sim \mathsf{Unif}(0,1)$. For example a random variable from $\mathsf{Exp}(1)$ with density function $f(x) = e^{-x},$ for $x > 0,$ can be generated as $X = -\log_e(U)$. Even discrete random variables are generated from uniform ones: for example $Y \sim \mathsf{Binom}(1, .5)$ can be generated by taking $Y = 0$ if $U < .5,$ and $Y = 1,$ otherwise.

So it is easy to see how a CS professor could insist that the source of all computer generated random models is a distribution that is uniform on $(0,1)$ (but not uniform on all real numbers). In fact, however, digital computers do arithmetic on an extremely large subset of the rational numbers--not on all real numbers, not even on all real numbers in $(0,1).$


Here is how one could simulate 6000 tosses of a fair die using R statistical software. The function sample is based on pseudorandom numbers indistinguishable from $\mathsf{Unif}(0,1).$ The argument rep=T indicates that sampling is done 'with replacement'. The output consists of approximately equal frequencies for each of the faces 1 through 6--nearly enough equal that they pass a 'goodness-of-fit' test. (Of course, if all six counts were exactly 1000, one would be suspicious that randomness is not being properly simulated.) The plot shows simulated results; red dots atop bars are at the theoretical probabilities $1/6$ for each face of the die.

x = sample(1:6, 6000, rep=T)
table(x)
##  x
##    1    2    3    4    5    6 
##  999  983 1003  983 1016 1016 

enter image description here