# Random number generator

Let's take a random number generator,f, which generated number from let say 1 to 1000, uniformly at random. Now I want to generate 10 numbers uniformly at random from 1 to 100. So if I use f and generates random numbers and take numbers which are in the range 1 to 100, discard otherwise, will those be uniformly at random or not? Why so?

Argument from my side, The probability of coming any number from 1 to 100 in our pick is 1/1000 and it is equally likely for all (I think there is some flaw in this argument but I am not able to find one). So if its true, all the number are equally likely from 1 to 100. That's why they should be random.

• $P($"generated number equals $x$"$) = { P(f_\imath = x) \over P(f_\imath \le 100)}$. Note that it's important that your generator values are independent (for example, if probability of getting even value after value $\ge 900$ isn't $1/2$, the statement would be false even if any given value is uniformly distributed). – Abstraction Sep 6 '16 at 9:45
• @Abstraction The generator values are totally independent. And in the Probability term that you have written, isn't there should be an 'and' in the numerator stating f_{i}<=100? Also the example that you have given is for the case when generator values are not independent,right?? – arman Sep 8 '16 at 7:29
• Expression I wrote is for conditional probability (provided $x \le 100$): $P($"generated number equals $x$"$) = P(\{f_\imath = x | f_\imath \le 100 \})$. And yes, the example was to show that condition "every single variable has uniform distribution" is not enough (and having low correlation between consecutive values is tricky when creating real-life generators, to my knowledge). – Abstraction Sep 8 '16 at 8:52