FIRST-Tech-Challenge / scorekeeper

FIRST Tech Challenge Live Scorekeeper Software
87 stars 21 forks source link

Randomization Doesn't Feel Random #320

Closed jkelbick closed 5 years ago

jkelbick commented 5 years ago

One of the two fields we ran this weekend came up with gold in the middle position for 10/12 matches. Is there anything that can be done to make the randomization feel more random?

cmacfarl commented 5 years ago

The software uses the Java Random class, and while it instantiates a new instance of Random for each invocation, the Oracle documentation on the subject indicates that the seed is very likely to be distinct from any other invocation of the constructor.

See: https://docs.oracle.com/javase/8/docs/api/java/util/Random.html

I personally have not seen this at any of the meets I've attended this year.

rgutentag commented 5 years ago

At our last event using 7.2 we saw the same thing. Our first five matches were gold in the center. Then it started to get more random but many more were gold center than anything else. I plan to watch our events this weekend to see if the same thing occurs again.

jvens commented 5 years ago

I have been running the system every weekend for the last several months now and I have not seen this happen. In a truly random system any sequence is equally likely to occur including a sequence of 10 centers. The exact implementation used to choose a random number in the system is these two lines of code:

Random r = new Random();
this.randomization = r.nextInt(6) + 1;

As @cmacfarl mentioned, the Random() constructor seeds the random number generator with a distinct value on each invocation. Therefore the random number is truly random each and every time.

HDMScot commented 5 years ago

Even a broken clock is right twice a day...

We concur that the randomization APPEARS to be not-so-random, especially since the starting position is frequently the randomized position. Are you truly randomizing only the one element (the gold)?

At our league tournament, 32 Qualifications matches and the majority were gold-center.

adwiii commented 5 years ago

The internal code "rolls a die" (selects a random number between 1 and 6) and then displays this die face on the screen and the corresponding randomization.

In our testing of running 1000 trials, we found the following results: image with the longest consecutive streak being 9. Interestingly, gold in the center happened to be the least frequent in this test, even though that is what was noted as being the most above.

The fact that there are only 3 choices for the gold position means that it is very likely that there will be a perceived bias, especially given that our sample sizes are small across one event.

After the season we can try to do some more aggregate data collection and see if that warrants a change in the randomization methodology, but at this point we do not feel that there is sufficient statistical evidence to warrant a change.

HDMScot commented 5 years ago

Data wins! You have shown the data that I suggest closing the issue for now.