Computing the cdf of some Discrete Distribution... I'm trying to find the cdf of the following discrete distribution:
$$f(k)=\frac{(1-\rho )^2 \rho ^{k-1}}{\left(1-\rho ^k\right) \left(1-\rho ^{k+1}\right)}+\frac{(1-\rho ) \rho ^{M-1}}{1-\rho ^M}$$
with domain of support
$$k\in \{1,...,M-1\}, k < M, \mbox{and}\ M \in Z.\ \mbox{Also}, 0<\rho<1.$$
I know its a proper pmf because, when $M=10$, I can compute
$$\sum _{k=1}^9 \left(\frac{(1-\rho )^2 \rho ^{k-1}}{\left(1-\rho ^k\right) \left(1-\rho ^{k+1}\right)}\right)+\frac{(1-\rho ) \rho ^{9}}{1-\rho ^{10}} = 1.$$
I'd like to compute the cdf, but I simply don't know how to do this. I can compute the pmf from the cdf for other distributions, but I can't do it in reverse.
Any help would be greatly appreciated.
 A: Consider the sequences:
$$g_n=(1-\rho)\frac{\rho^{n-1}}{1-\rho^n}~~,~~f_n=(1-\rho)^2\frac{\rho^{n-1}}{(1-\rho^n)(1-\rho^{n+1})}$$
It is easy to see that the sequence $g$ is an "integral" to the sequence $f$, in other words:
$$g_{n+1}-g_{n}=-f_n$$
Then we see that the sum telescopes
$$\sum_{n=1}^{M-1}f_n=g_1-g_M=\frac{1-\rho^{M-1}}{1-\rho^M}=1-(1-\rho)\frac{\rho^{M-1}}{1-\rho^M}$$
This shows us that if the sequence g which is the "integral" is to be considered as a CDF then the corresponding PMF meaning must be assigned to $$t(n;M)=\begin{Bmatrix}f_n&~~0\leq n\leq M-1\\\frac{\rho^{M-1}}{1-\rho^M}&~~n=M\\ 0& \text{otherwise}\end{Bmatrix}$$
The corresponding CDF then is:
$$T(n;M)=\sum_{k=1}^{n}t(k;M)=\begin{Bmatrix}-g_{n+1}+g_1&~~1\leq n\leq M-1\\1&~~n=M\\ \end{Bmatrix}$$
A: Given
$f(x)=
\begin{array}{lc}
  & \left\{
\begin{array}{cc}
 \frac{(1-\rho )^2 \rho ^{x-1}}{\left(1-\rho ^x\right) \left(1-\rho ^{x+1}\right)} & x\leq M-1 \\
 \frac{(1-\rho ) \rho ^{M-1}}{1-\rho ^M} & x=M \\
\end{array}
 \\
\right.
\end{array}
$
We can calculate the cdf by:
$
F(k)=\sum _{x=1}^k f(x) =
$
$$
\begin{array}{cc}
 & \left\{ 
\begin{array}{lc}
 1 & (k=1\land M=1)\lor (M=2\land k\geq 2) \\
\frac{1}{1+\rho} & (k=1\land M\geq 2)\lor (M=2\land k>1\land k<2) \\
 \frac{1-\rho ^k}{1-\rho ^{k+1}} & k>1\land k+1\leq M \\
  \frac{\rho -\rho ^{ M }}{\rho -\rho ^{ M +1}} & k<M\land k+1>M\land M>2 \\
 \frac{(1-\rho) ( M -2) \rho ^{M-1}}{1-\rho ^M} & k>1\land k\geq M\land M\geq 1\land M<2 \\
 \frac{(1-\rho) \rho ^M  \left(1-\rho ^{ M }\right)+\left(1-\rho ^{M+1}\right) \rho ^{ M }-2 \rho ^{M+1}+\rho ^M+\rho }{\rho  \left(1-\rho ^M\right) \left(1-\rho ^{ M }\right)} & k\geq M\land M>2 \\
\end{array}
 \\
\right.
\end{array}
$$
