5

Let's say I have a random number generator from which I am requesting values for event A and event B. Both events occur at random intervals but event A happens much more often than event B and I would still want both the values sampled for event A as well as values sampled for event B to be uniformly random in their own right.

I can imagine this would be no issue for a truly random number generator, but what about an algorithmical pseudo random generator, let's say java.util.Random? Would I be safer to use separate instances of the generator for event A and event B?

  • My maths is too poor for a proof, but it should not make a difference if the generator has a good quality (that is the number spectrum is well distributed). You'd get the same spread irrelevant of the number of samples you take. – qwerty_so Nov 19 '16 at 14:14
  • No, the distribution is random... – HorusKol Nov 19 '16 at 14:23
  • 1
    Depends. How lucky are you feeling? – candied_orange Nov 19 '16 at 18:39
  • just use SecureRandom class – Display Name Nov 20 '16 at 8:29
  • SecureRandom uses the operating system's entropy (which I may need to wait for) and besides, I don't need unpredictability here, just a uniform distribution. I would rather use two ordinary Random instances, but I am curious if I have a problem at all? – gregopet Nov 20 '16 at 13:29
3

Is a random sample from a range of uniformly distributed values still uniformly distributed?

If I give you a blank 6 sided die and tell you to write values on it as I roll them on my normal 6 sided die this might happen:
1,2,3,4,5,6

And congrats you got a normal fair die. But if I had rolled:
1,2,3,4,5,5

Sorry but your die isn't fair. Those values aren't normally distributed. Even though my die was fair and its face values are normally distributed.


Let's say I have a random number generator from which I am requesting values for event A and event B. Both events occur at random intervals but event A happens much more often than event B and I would still want both the values sampled for event A as well as values sampled for event B to be uniformly random in their own right.

This creates the possibility of a counting error. So long as you understand your sample as being states at sampled times and not as a number of events the discrepancy between event A and event B is fine. What you've done is entangle time into your data. If you need to know how many times the events happened you can't get it this way.

I can imagine this would be no issue for a truly random number generator, but what about an algorithmical pseudo random generator, let's say java.util.Random? Would I be safer to use separate instances of the generator for event A and event B?

An algorithmic pseudo random generator is not going to be a problem here so long as it's fair. You could use the digits of PI. There is no requirement to be unpredictable here. Just uniform.

Same reason that it's no problem that my die seems to always roll numbers in order. The test for uniformity doesn't care about that.

So understand what your sample produces has every right to not be uniform even if what produced it was uniform. The larger the sample though the closer it should tend towards being representative of the data. That's the law of large numbers. It's a very powerful tendency but the test for uniformly distributed is very finicky. So much so you rarely see it in data. Only in idealized constructs.

What you can do is look at enough rolls of my "fair" die and tell how likely it is I'm lying about it being fair. While what it produces doesn't have to be uniform it looks suspicious if a large number of rolls don't tend towards uniformity.

Put simply, there only so many times I can roll anything but a 6 before you should think it's more likely I'm messing with you.

  • Thanks, the law of big numbers is precisely what I'm trying to understand in this case - otherwise I could simply create an experiment taking a 'large enough' number of samples and see if I'm 'happy' with the results. I also agree that unpredictability is not required here. As for fairness, that's precisely what I'm trying to determine in this case, but digits of PI are not my source of randomness: an algorithm is. Instictively I feel you are right and this does not matter, but I would love some kind of 'stricter' answer :) – gregopet Nov 20 '16 at 13:27
  • I think you should elaborate on your die rolling example as I don't think it's clear. – whatsisname Nov 25 '16 at 5:38
0

You should ask this on https://stats.stackexchange.com/

So the generator may not be perfect.

Splitting it in two generators is not going to help. If a generator biases to an event then it is not random. If it gave out 3 low numbers it is not going to bias to a big number to bring up the average.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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