I'm writing a program for an assignment for my Probability and Statistics course. This program performs several millions of simulated coin tosses, and then analyses various properties of the generated sequence.
One of the things it does is count how many runs does the generated sequence contain, and their lengths. One result for 10.000.000 tosses is:
Number of runs of length 1 is: 2500986 Number of runs of length 2 is: 1246647 Number of runs of length 3 is: 625656 Number of runs of length 4 is: 311689 Number of runs of length 5 is: 156673 Number of runs of length 6 is: 78464 Number of runs of length 7 is: 39253 Number of runs of length 8 is: 19547 Number of runs of length 9 is: 9866 Number of runs of length 10 or more is: 9818
Now, my problem is following: I need to compare the result acquired by simulation to theoretical expectation of sorts. Basically, I need that same result as above, calculated on paper.
A pattern in the results obviously exists, but I just cant figure out a formula. Anyone, help please?