Two ways to find generating functions, strangely inconsistent

52 Views Asked by At

As a self-learner, I have been trying to solve the following problem:

Independent of each other, you generate integers at random from 0,1, ..., 9 until a zero is obtained. Use the method of first-step analysis to obtain the generating function of the sum of the generated integers.

Let S be the sum of generated integers, p = 1/10 be the probability of obtaining any number at a trial, and $X_1$ be the integer obtained at the 1st trial.

Using first-step analysis as suggested, the generating function G is given by $G_S(z) = E(z^S) \\ = E(z^S|X_1 = 0) P(X_1 = 0) + \sum_{k=1}^9 E(z^{S}|X_1 = k)P(X_1 = k)\\ = p+p\sum_{k=1}^9 E(z^{S+k})\\ = p + p \sum_{k=1}^9 E(z^{S+k}) \\ = p + p E(z^S)\sum_{k=1}^9 z^k $.

Therefore, $G_S(z) = E(z^S) = \frac{p}{1-p \sum_{k=1}^9 z^k}$.

This should be correct, right? I tried using another method to verify the result above, and that's where the inconsistency happens...

The number of trials $N$ actually follows a geometric distribution with "success" probability $p = 1/10$. (Success means drawing a 0 and therefore the game ends.) In addition, at each draw we get 0...9 with uniform probability. Therefore,

$G_S(z) = \sum_{s} P(S = s)z^s \\ = \sum_{n=1}^{\infty}\sum_{s} P(S=s|N=n) \times P(N=n) \times z^s \\ = \sum_{n=1}^{\infty} (1-p)^{n-1}p\times \left( \sum_{s}P(S = s|N = n)z^S \right) $

The $S$ sum gives the generating function of the integer sum, after fixed $N=n$ trials: $A(z)^n = \left[ p(\sum_{k=0}^9 z^k) \right]^n \leq 1$.

Evaluating the geometric series in $n$, we finally get $\frac{p}{1-p} \times \sum_{n=1}^{\infty}(1-p)^n A(z)^n \\ = \frac{p A(z)}{1 - (1-p)A(z)}$.

Which if expanded out is inconsistent with my first result! What could have gone wrong here?

EDIT: maybe the mistake is with the form of $A(z)$. As it stands it corresponds to trials where we obtained a 0 but didn't stop.

1

There are 1 best solutions below

2
On BEST ANSWER

Your first approach is fine.

In your second we meet $P(S=s\mid N=n)$.

Here: $$P\left(S=s\mid N=n\right)=P\left(\sum_{k=1}^{n-1}X_{k}=s\mid\prod_{k=1}^{n-1}X_{k}\neq0\right)=P\left(\sum_{k=1}^{n-1}Y_{k}=s\right)$$ where the $Y_{k}$ are iid and uniformly distributed on $\left\{ 1,2,3,4,5,6,7,8,9\right\}$.

This in order to achieve that $P(Y_k=i)=P(X_k=i\mid X_k\neq0)$.

We find:

$$\sum_{s=0}^{\infty}z^{s}P\left(S=s\mid N=n\right)=\sum_{s=0}^{\infty}z^{s}P\left(\sum_{k=1}^{n-1}Y_{k}=s\right)=\mathbb{E}z^{\sum_{k=1}^{n-1}Y_{k}}=\left(\mathbb{E}z^{Y_{1}}\right)^{n-1}=\left(\frac{1}{9}\sum_{i=1}^{9}z^{i}\right)^{n-1}$$

and consequently:

$$\mathbb{E}z^{S}=\sum_{n=1}^{\infty}P\left(N=n\right)\left(\frac{1}{9}\sum_{i=1}^{9}z^{i}\right)^{n-1}=\mathbb{E}\left(\frac{1}{9}\sum_{i=1}^{9}z^{i}\right)^{N-1}=\frac{1}{10-\sum_{i=1}^{9}z^{i}}$$

This agrees with the first result.