Randomy generated numbers – Probability of Running Sums
Draws are independent and uniformly chosen from the set
(with unlimited repetition).
Let
denote the probability that at some time the running sum equals exactly
.
1. Recurrence
With the convention
for
and
, the probability satisfies the recurrence
![Rendered by QuickLaTeX.com \[ p(0)=1,\qquad p(n)=\frac{1}{k}\sum_{i=1}^{k} p(n-i)\quad\text{for }n\ge1. \]](https://stationarystates.com/wp-content/ql-cache/quicklatex.com-41428cff655fc29ed6cf5cc17219898a_l3.png)
(This comes from conditioning on the value of the first draw: if the first draw is
then we must subsequently hit
.)
2. Generating function
Let
. Summing the recurrence gives the closed form
![Rendered by QuickLaTeX.com \[ P(x)=\frac{1}{1-\dfrac{x(1-x^k)}{k(1-x)}}. \]](https://stationarystates.com/wp-content/ql-cache/quicklatex.com-36ff3c7ebc7f239ea0b1c072b5cbb4d9_l3.png)
Equivalently,
![]()
The coefficient of
in this rational function equals
.
3. Combinatorial (explicit) formula
Another useful representation counts ordered compositions of
into
parts each in
.
If
denotes the number of such compositions with exactly
parts, then
![]()
By inclusion–exclusion one can write
![Rendered by QuickLaTeX.com \[ c_{n,m}=\sum_{j=0}^{\left\lfloor\frac{n-m}{k}\right\rfloor} (-1)^j\binom{m}{j}\binom{n-jk-1}{m-1}, \]](https://stationarystates.com/wp-content/ql-cache/quicklatex.com-9cccd2895c6af43bcc7b8c3e982097e1_l3.png)
so a fully explicit formula is
![Rendered by QuickLaTeX.com \[ \boxed{\,p(n)=\sum_{m=1}^{n}\frac{1}{k^m}\sum_{j=0}^{\left\lfloor\frac{n-m}{k}\right\rfloor} (-1)^j\binom{m}{j}\binom{n-jk-1}{m-1}\, }. \]](https://stationarystates.com/wp-content/ql-cache/quicklatex.com-5be98c5be4d39a6ba4fe2da88f6f89b9_l3.png)
4. Remarks and small cases
:
for every
(every draw is 1 so every positive integer is hit).
:
with
; values can be computed quickly from the recurrence.- The generating function form is convenient for extracting asymptotics or for computing
by partial fractions (roots of the denominator polynomial).
Recap (as before): draws are iid and uniform on
. Let
be the probability that some partial sum equals exactly
.
With the convention
for
and
,
![Rendered by QuickLaTeX.com \[ p(n)=\frac{1}{k}\sum_{i=1}^{k} p(n-i)\qquad (n\ge1). \]](https://stationarystates.com/wp-content/ql-cache/quicklatex.com-6ccefdbfd9a1d9c824781b47bf672fe7_l3.png)
Numerical examples
Below are computed values of
for
and
. (Remember
.)
| n | |
|---|---|
| 0 | 1.000000000000 |
| 1 | 0.500000000000 |
| 2 | 0.750000000000 |
| 3 | 0.625000000000 |
| 4 | 0.687500000000 |
| 5 | 0.656250000000 |
| 6 | 0.671875000000 |
| 7 | 0.664062500000 |
| 8 | 0.667968750000 |
| 9 | 0.666015625000 |
| 10 | 0.666992187500 |
| 11 | 0.666503906250 |
| 12 | 0.666748046875 |
| n | |
|---|---|
| 0 | 1.000000000000 |
| 1 | 0.333333333333 |
| 2 | 0.444444444444 |
| 3 | 0.592592592593 |
| 4 | 0.456790123457 |
| 5 | 0.497942386831 |
| 6 | 0.515775034294 |
| 7 | 0.490169181527 |
| 8 | 0.501295534217 |
| 9 | 0.502413250013 |
| 10 | 0.497959321919 |
| 11 | 0.500556035383 |
| 12 | 0.500309535772 |
| n | |
|---|---|
| 0 | 1.000000000000 |
| 1 | 0.250000000000 |
| 2 | 0.312500000000 |
| 3 | 0.390625000000 |
| 4 | 0.488281250000 |
| 5 | 0.360351562500 |
| 6 | 0.387939453125 |
| 7 | 0.406799316406 |
| 8 | 0.410842895508 |
| 9 | 0.391483306885 |
| 10 | 0.399266242981 |
| 11 | 0.402097940445 |
| 12 | 0.400922596455 |
Observations
- For
the probabilities converge quickly to
(the table shows values oscillating about that limit). - For
and
the values for moderate
tend to a limiting value (the limit exists and equals the reciprocal of the mean waiting-time to cross a large interval — this can be analyzed via renewal theory or by studying the generating function). Numerically you can see the values settle near about
for
and near
for
at the
shown.
— End
— End