Suppose a number is chosen randomly between $\{0,1, \cdots 99 \}$. Let X denote the sum of the digits of the selected number. I am interested in the p.m.f of X.
Here is my approach:
Let $u =\{0,1, \cdots 9\}$, $v=\{0,1,\cdots 9\}$
Define $$ h = 10u +v $$ such that $$h=\{0,1,2,\cdots 99 \} $$
$$ f(x)=f(k)= \sum_{k} f(k=u+v \mid h)\frac{1}{100}$$ $k \in \{0,1 \cdots 18\}$
Using generating function solution:
$$ \begin{align} f(k=u+v\mid h) = f(x) &= (1+x+x^2+\cdots + x^9 ) (1+x+x^2+\cdots + x^9 ) \\ &= \frac{1-x^{10}}{1-x} \times \frac{1-x^{10}}{1-x} \\ &= (1-x^{10})^2 \frac{1}{(1-x)^2} \end{align}\\ f(k=u+v\mid h) = (1-x^{10})^2 \sum_{k=0}^\infty {2+k-1 \choose k } x^k = (1-2x^{10} +x^{20}) \sum_{k=0}^\infty {2+k-1 \choose k }x^k$$
For each $k$, we fill up the table below using the formulation above. Thus:
$$k= 0 \implies {2+0-1 \choose 0 } =1 \\ k= 1 \implies {2+1-1 \choose 1 } =2 \\ k= 2 \implies {2+2-1 \choose 2 } =3 $$
For $k = 10$: $$\begin{align} &k= 10 \implies {2+10-1 \choose 4 } - 2 {2+0-1 \choose 0 } =9 \\ &k= 11 \implies {2+11-1 \choose 11 } - 2 {2+1-1 \choose 1 } =12-4=8 \end{align}$$
The table for $f(k\mid h) = \{1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1 \}$ for $k=\{0,1,2, \cdots 18\}$.
Then $f(x)$ follows by dividing each value by $100$
Is this approach generally okay? Anything to improve here?