This question already has an answer here:

Let's assume we have an unfair coin and a machine that toss it continuously. We counted the number of tandem heads. Whenever it's head we count 1, if it's head again, counter goes to two and so on. When we get our first tail, it reset to zero.

Here's the result of tossing: [H,H,T,H,H,H,T,H,T,T]

Collected data: [1,2,0,1,2,3,0,1,0,0]

The thing I'm interested in is to read the past x readings and predict the next tossing result.

For example, assuming this data, the maximum number or continuous heads in the past 5 readings was 3, how can we translate it to a probability of the next tossing.


marked as duplicate by whuber Sep 21 '18 at 18:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Since you can easily recover the tossing result from the collected data, why do you introduce the complication of the counter? $\endgroup$ – whuber Sep 21 '18 at 17:28
  • $\begingroup$ I want to use the past distribution of continuous heads to update my assumption on the fairness of the coin. We don't know anything about how unfair the coin is. $\endgroup$ – Mehdi Zare Sep 21 '18 at 18:07
  • $\begingroup$ We have a great many threads about this: bayes beta binomial. $\endgroup$ – whuber Sep 21 '18 at 18:29
  • $\begingroup$ I read more than ten of those, and couldn't find anything similar to my question. Key differences, the coin is not fair and its unfairness can change over time, the most recent outcomes are the most probable ones, so I want to use a distribution that changes over time. It's a continuous tossing machine, and I want to update my assumption as the time passes. $\endgroup$ – Mehdi Zare Sep 21 '18 at 18:59
  • $\begingroup$ Every one of those posts concerns possibly biased coins. After all, if the coin isn't biased, what's the point to sampling it? We do have a post on modeling time-varying coins at stats.stackexchange.com/questions/32991/…. This is so different that it's crucial you modify your question to reflect what you're actually interested in. $\endgroup$ – whuber Sep 21 '18 at 19:16