# Geometric distribution formula derivation

Could someone help me understand how we get from sum to one in this formula of geometric distribution. Probably, some simplification I don't see

Formula

The formula for the geometric distribution is $$P(X=n)=p(1-p)^{n-1}$$ with $$n\in \mathbb{N}-\{0\}$$, adding the terms we have:

$$S=\sum_{n=1}^{\infty}P(X=n)=\sum_{n=1}^{\infty}p(1-p)^{n-1}$$, we can change the variable like $$j=n-1$$, so if $$n=1$$ then $$j=1-1=0$$, then the sum $$S$$ is:

$$S=\sum_{j=0}^{\infty}p(1-p)^{j}=p\sum_{j=0}^{\infty}(1-p)^{j}$$

Using the geometric sum for $$|x|<1$$, $$\sum_{j=0}^{\infty}x^j=\frac{1}{1-x}$$, then S is equal to $$S=p\frac{1}{1-(1-p)}=1$$, where we used the geometric sum with $$x=1-p$$.

Let $$q:=1-p$$. Then write the sum

$$S:=1+q+q^2+\cdots$$

You observe that

$$qS=q+q^2+q^3+\cdots=S-1$$ or $$S=\frac1{1-q}=\frac1p$$

so that

$$pS=1.$$