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 - ScrollTo Effect (href to div) -

javascript - ng-class not responding to change in model in Angular? -

javascript - document.registerElement extending HTMLInputElement prototype while using custom tag name to avoid implicit browser style -