Looking to find the expected value/variance of the following geometric variable defined as having success rate p, where trials are taken until we have a success (which happens with probability p) or we have taken n trials. Successfully calculated the expected value, and ideas on variance? Not sure how to proceed.
For expected value, first tried to use the definition of expectation (and LOE), but got a pretty ugly expression: $\sum_{i=1}^{n-1}{i(p)(1-p)^{i-1}} + n(1-p)^{n-1}$. Is there any nice formula/trick for solving this question?
So the most straightforward way to proceed from what you have is to use the fact that
$$ \sum_{i = 0}^{n - 1} x^i = \frac{1 - x^{n}}{1 - x}$$
So if you differentiate with respect to $x$ you get
$$ \sum_{i = 0}^{n} i x^{i - 1} = \frac{-nx^{n - 1}(1 - x) + (1 - x^{n})}{(1 - x)^2}.$$
Then you want to substitute $x = 1 - p$ and also multiply both sides by $p$. Admittedly, it's not the prettiest expression but it's not too bad either.