Finding a probability of a process from a distribution of how long it takes before it happens Good day, 
I am looking to solve a statistical problem, namely of finding the probability of something happening, from the distribution of how long it takes before it happens.
So what I have is a system that can be in state S1, and it transitions to state S2 with probability P. From time to time it returns to S1, and then it can again transition to S2 with probability P.
Now, it is this P I am after. What I know is the following. I have a distribution of how many 'timesteps' the system stays in S1 before going to S2. So this is basically an array of the form [1 2 1 12 15 8 2].  
So I know the distribution of how many times it does not transition, before doing so.
What I have thought of is that this is obviously a binomial distribution. However, the parameters of the distribution are not clear to me. It seems as if the number of repetitions N and the amount of times something happens k are constantly changing, depending on what value I take from my array. Is there a clever way to go about this?
 A: if $P(S_1\rightarrow S_2)=p$ for each timestep that the system is in state $S_1$, then the number of turns that the system spends in $S_1$ before transitioning to $S_2$ will not have a binomial distribution, but a geometric distribution with parameter $p$. 
You also have a vector of N elements, with each element indicating how many turns the system remains in $S_1$ before it goes to $S_2$ (i.e., if the first element in the vector is 2, then we know that at T=3 the system was in state $S_2$, correct?).
Therefore, your vector represents a sample of size N from a geometric distribution with parameter $p$. 
The final insight into your problem is that each observation is independent, since the probability, $p$, doesn't change over time, therefore, each element in your vector of observations stands on its own, unaffected by the observations before or after it.
Taking all this together, you can apply the maximum likelihood estimate for a geometric random variable to your vector of observations, $\mathbf{x}:=\{x_1,x_2...x_N\} : \hat p_{MLE} = \frac{N}{\sum_{i=1}^N x_i}$, which is just the total number of jumps from $S_1\rightarrow S_2$ divided by the total number of time periods the syatem was in state $S_1$..
Lets apply this to your example vector: [1 2 1 12 15 8 2]. The vector has 7 elements, so we observed N=7 jumps from $S_1\rightarrow S_2$. The total time the system was in $S_1$ during the observation period is the sum of the elements of the vector, which is 41 time periods. Therefore, you saw 7 transitions in 41 total time periods giving an estimated value for P of $\frac{7}{41} \approx \frac{1}{6}$ 
