javascript - Algorithm for consecutive n-head -


i have tackle statistics problem current project: given series of coin flips, calculate percentage of consecutive n-heads runs. data bellow, 1 head , 0 tail. found this reference probability of n-heads , have no clue of how apply deride algorithm (javascript prefered). appreciate hints. thanks!

flips = [1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0. 0];

edit:

  1. the coin not fair coin next outcome of flip based on history. example, don't see 3-tails run (3 zeroes in row) in history chance of next outcome 0%.

  2. so, interpretation of percentage of consecutive n-heads runs probability of outcome of next flip. :)


Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -