Probability of event A happening is 0.53. What is the probability of event A occuring 4 times in a row over 63 samples? I am working on a personal project where I need the probability of the following scenario:
There are 53 blue balls and 47 red balls in a bag. If I draw 63 balls from the bag (with replacement), what is the probability that a blue ball will be drawn 4 times in a row at least once?
The 'in a row' part of this question is throwing me off, I can't seem to figure out how to think about this.
Update: I wrote a little python script to simulate this scenario, resulting in an average occurrence rate of 93.7% over 1 million simulations. Though I am very interested in the math behind this for verification.
 A: You can calculate the exact figure with a recurrence:
Let $f(n,k)$ be the probability that after $n$ draws with replacement you have not seen four consecutive blue balls but you have seen the last $k$ balls blue.  You then have
$$f(0,0)=1$$
$$f(0,1)=f(0,2)=f(0,3)=0$$
$$f(n,1)=0.53 f(n-1,0)$$
$$f(n,2)=0.53 f(n-1,1)=0.53^2 f(n-2,0)$$
$$f(n,3)=0.53 f(n-1,2)=0.53^3 f(n-3,0)$$
$$f(n,0)=0.47 (f(n-1,0)+f(n-1,1)+f(n-1,2)+f(n-1,3)) \\ =0.47 (f(n-1,0)+0.53 f(n-2,0)+0.53^2 f(n-3,0)+0.53^3 f(n-4,0))$$
The probability you want is $$1-f(63,0)-f(63,1)-f(63,2)-f(63,3) \\= 1 -\tfrac{1}{0.47}f(64,0)$$ and if you apply the recurrence you get about $0.9367376$, close to the simulation
A: Let $A_n$ denote the ways to draw 4 successive blue balls in $n$ draws.
Now let $d$ be a drawing of $n$ balls in which we have 4 successive blue balls. Then no matter how we extend $d$, we still have 4 successive blue balls.
On the other hand, the only drawings in $A_{n+1}$ which are not obtained by extending a drawing from $A_n$ are those where in the first $n$ balls, there is no occurence of 4 blue balls, however the last 4 balls $n-2,n-1,n,n+1$ are all blue. From this also follows, that the ball $n-3$ has to be red. 
So we can just take any drawing in $A_{n-4}^C$, i.e. any drawing of $n-4$ ball that contains no 4 successive blue balls, and add 1 red, and 4 blue balls to its end.
So we have
$$
A_{n+1}= \{w\hat\times \{0,1\}\mid w\in A_n\}\,\,\dot\cup \,\,\{w\hat\times (0,1,1,1,1)\mid w\in A_{n-4}^C\}
$$
(where we define $A\hat\times B$ as the set $A\times B$, but with each element flattened; The $\dot\cup$ means it's a disjoint union)
Therefore we have:
$$
\mathbb P (A_{n+1})= \mathbb P(\{w\hat\times \{0,1\}\mid w\in A_n\})\,\,+ \,\,\mathbb P(\{w\hat\times (0,1,1,1,1)\mid w\in A_{n-4}^C\})
\\ = \mathbb P(A_n) + (1-\mathbb P(A_{n-4}))\cdot \frac{47\cdot 53^4}{100^5}
$$
Add in the start cases $\mathbb P(A_1)=\mathbb P(A_2)=\mathbb P(A_3)=0, \mathbb P(A_4) = \frac{53^4}{100^4}, \mathbb P(A_5) = 2\cdot \frac{53^4\cdot 47}{100^5} + \frac{53^5}{100^5}$, and you obtain
$$ \mathbb P(A_{63}) = 0.9367376$$
Python code:
f_dict = dict()


def f(n):
    try:
        return f_dict[n]
    except KeyError:
        if (n > 5):
            f_dict[n] = f(n - 1) + (1-f(n - 5)) * (47 * 53 ** 4) / 100 ** 5
            return f(n)
        elif (n == 5):
            f_dict[n] = 2 * (53 / 100) ** 4 * (47 / 100) + (53 / 100) ** 5
            return f(n)
        elif (n == 4):
            f_dict[n] = (53 / 100) ** 4
            return f(n)
        else:
            return 0


print(f(63))

