With this problem it is a challenge already to provide a numerical
answer that can be used to check the results from probabilistic
methods. This can in fact be done, and I will show how. Suppose we
have $n$ flips and we are looking to count outcomes where a lead of at
least $q$ was obtained at some point. The idea is to use a Markov
chain with states $T$ and $A_p$ where $-(q-1)\le p\le q-1.$ The state
$A_p$ represents the lead $p$ with the obvious transition rules that
this implies. Finally $T$ is an absorbing state where the chain
remains once a lead of $q$ has been seen. We solve this system of
equations and obtain $T.$ We get for the present problem which has
$q=10$
$$\bbox[5px,border:2px solid #00A000]{
T(z) = {\frac {2{z}^{10}}{ \left( 2\,{z}^{10}-25\,{z}^{8}
+50\,{z}^{6}-35\,{z}^{4}+10\,{z}^{2}-1 \right)
\left( 2\,z-1 \right) }}.}$$
It remains to compute
$$\frac{[z^{300}] T(z)}{2^{300}}.$$
Extracting the coefficient we get
${ 1.9744763278096917789\times 10^{90}}$
which yields for the probability of having seen a lead of at least ten
at some point during $300$ flips the value
$$\bbox[5px,border:2px solid #00A000]{
0.96928888382356097067.}$$
Observe that we used the Maple series command to extract the
coefficient. This can be replaced if desired by converting $T(z)$
numerically into a partial fraction decomposition and computing the
coefficients from a geometric series (I have tested this).
The Maple code for this including an enumeration routine to check
the result from the Markov chain, is as follows. We can of course
solve for $T$ manually but here it has retained the format from the
system of equations.
X :=
proc(q)
option remember;
local sys, pos, sol, eq;
sys := [A[-(q-1)] = z * A[-(q-2)],
A[q-1] = z * A[q-2]];
for pos from -(q-2) to q-2 do
sys :=
[op(sys),
A[pos] + `if`(pos=0, -1, 0) =
z * A[pos-1] + z * A[pos+1]];
od;
sol := solve(sys, [seq(A[p], p=-(q-1)..q-1)]);
eq := T = 2*z*T +
z * subs(op(1, sol), A[-(q-1)] + A[q-1]);
solve(eq, T);
end;
Q := (n, q) ->
coeff(series(X(q), z=0, n+1), z, n);
ENUM :=
proc(n, q)
option remember;
local ind, res, lead, d, pos;
res := 0;
for ind from 2^n to 2^(n+1)-1 do
d := convert(ind, base, 2);
lead := 0;
for pos to n do
if d[pos] = 1 then
lead := lead + 1;
else
lead := lead - 1;
fi;
if lead = q or lead = -q then
break;
fi;
od;
if pos < n+1 then
res := res + 1;
fi;
od;
res;
end;
This method is computation intensive. We hope to see the numerics
verified by a future post.
What we have here is closely related to the DFA
method.
There is, among others, this entry at the OEIS, OEIS A216212.
set.seed(0); a = replicate(10^5, sample(c(-1, 1), 300, replace = T)); momentary_score = apply(a, 2, function(x) cumsum(x)); mean(apply(momentary_score, 2, function(x) sum(abs(x) > 9) > 0)) [1] 0.97006
. $97%.$ – Antoni Parellada Jan 11 '17 at 07:41