Hi, I am WasPentalive and I use C to create small programs to explore randomness and other interesting subjects. For example, I had heard that the chances of winning the CA lottery was the same as flipping a coin Heads or Tails 25 times in a row. I wrote a C program to flip coins until that streak was accomplished.
So are the chances the same?
mx: 1 heads: 0 tails: 1 Distance: 1 mx: 2 heads: 0 tails: 2 Distance: 1 mx: 3 heads: 0 tails: 3 Distance: 1 mx: 4 heads: 0 tails: 4 Distance: 1 mx: 5 heads: 1 tails: 10 Distance: 7 mx: 6 heads: 24 tails: 29 Distance: 42 mx: 7 heads: 135 tails: 146 Distance: 228 mx: 8 heads: 135 tails: 147 Distance: 1 mx: 9 heads: 135 tails: 148 Distance: 1 mx: 10 heads: 728 tails: 748 Distance: 1193 mx: 11 heads: 8478 tails: 8395 Distance: 15397 mx: 12 heads: 17542 tails: 17521 Distance: 18190 mx: 13 heads: 26467 tails: 26363 Distance: 17767 mx: 14 heads: 28703 tails: 28547 Distance: 4420 mx: 15 heads: 43479 tails: 43254 Distance: 29483 mx: 16 heads: 43479 tails: 43255 Distance: 1 mx: 17 heads: 43479 tails: 43256 Distance: 1 mx: 18 heads: 225204 tails: 224556 Distance: 363025 mx: 19 heads: 230017 tails: 229673 Distance: 9930 mx: 20 heads: 524886 tails: 525560 Distance: 590756 mx: 21 heads: 524887 tails: 525560 Distance: 1 mx: 22 heads: 4357778 tails: 4351432 Distance: 7658763 mx: 23 heads: 5071370 tails: 5064622 Distance: 1426782 mx: 24 heads: 5071370 tails: 5064623 Distance: 1 mx: 25 heads: 5071370 tails: 5064624 Distance: 1 Average distance : 405439.75 Ratio heads to tails: 1.00
For each landmark run the number of flips (heads and tails) is recorded. Distance is the number of flips since the last landmark run, where distance is 1 it means that another head or tail was flipped to continue an already landmark run. To reach the goal of 25 flips of the same side - one had to flip 10,135,994 coins.
So yeah. Your chances of winning the Lottery are about the same whether you buy a ticket or not.
I wonder what’s the best library in C to draw graphs about these stuff. If you use Python for that (such as Google Collab) that would be pretty straightforward.
I would probably have my program print the data in CSV format and then import it into Libra Calc (LibraOffice Spreadsheet) for all kinds of graphing.