Streaks.math
1r. Heads streak (for at least 1 of length X or more)
using the R code below
(this basic version differs from the Home page version as the code will NOT print the raised matrix)
call function like this: runs.r(5, 20, 0.5)
where run.r function = runs.r (run length, # of trials, trial prob of success)
press Run (or enter key)
One can a new call in the R Console and press enter
Note: Do NOT enter values with seperators. example: 10,000 is 10000. do not use the comma (,)
1 million is 1000000 (or better 1e6 or 10^6) and not 1,000,000 (code uses , for something else)
2r. Average number of trials for a run (streak)
with 2 or 3 outcomes, success or failure or a tie.
runs.mean3(run length, probability of success, probability of a tie)
examples: runs.mean3(5, 0.5) #fair coin flip call (tie default = 0)
runs.mean3(5, 949/1980, 55/1980) is for the don't pass bet in craps
3r. Heads or Tails streak (or both)
R code using Markov chain. p(heads) does not have to equal p(tails)
***** see section 4r. for Heads AND Tails *****
for Heads or Tails streak (NOT both)
some math required: (p(Heads) + p(Tails)) - (2 * p(Heads & Tails))
more to follow...
4r. Heads and Tails streak (heads 1st then tails or tails 1st then heads)
R code using Markov chain. p(heads) does not have to equal p(tails)
returns:
print(headsT.run) heads run 1st then tails run
print(tailsH.run) tails run 1st then heads run
print(tailsH.run + headsT.run) both possibilities
5r. Average (mean) number of streaks (runs) in N trials table. X and X or more
more on the call coming
6r. Heads run probability of length X. (not so common)
NOT 'X or more' that most streak calculators calculate.
Example would be for a run of length=3
at the beginning of N trials, HHHT or THHHT (during N trials) or at the end of N trials, THHH
call function: runs.Heads(lengthX, trials, one trial probability for Heads)