Neil deGrasse Tyson proposed a thought experiment involving 1000 coin flips. The intent was to show that within any random sample, there is bound to be a consistent "winner" that our human minds term as "lucky."
https://www.youtube.com/shorts/djv46ZfiVA0
Finding 1000 volunteers is expensive, plus the challenge of keeping them honest. So, we can run this thought-experiment more easily through simulation (assuming we have a reasonably good and balanced RNG).
This is also an example of using the BANK keyword, since I manage the memory myself instead of using DIM'd arrays. The default is set to 1000 participants, but if you change it to a small number of participants (under 60) the results are just shown onto the screen. For larger simulations, the results are written to a CSV file for a post-review (and verifying/finding that lucky winner!). This does mean you can scale it up to a max of 8192 participants (max size of a RAM BANK).
Another thing I did was kept metrics for both consecutive 0's and 1's (instead of just 1's). That is, each participant is assigned an "expected roll." We then count how many times their roll matches that initial expectation. This is a slight alternation to how deGrasse originally explained it, but still matches the intent (but shows "lucky" and "unlucky" cases, depending on what 0 or 1 represents). If the RNG is truly random, we'd expect the result to be balanced (with about half as many participants making it to the next round).
"1000COIN" Statistics Simulator (deGrasse coin flip experiment)
"1000COIN" Statistics Simulator (deGrasse coin flip experiment)
- Attachments
-
- COIN-8192.CSV
- (280.38 KiB) Downloaded 24 times
-
- 1000COIN.PRG
- (1.68 KiB) Downloaded 19 times
-
- 1000COIN.BASL.TXT
- (3.88 KiB) Downloaded 23 times