Need help to calculate and maximize cost-effective solution Suppose we have a task that can be a success or a failure. We pay a fee and get a success for any attempt at the task.
We can pay more in order to get a higher success rate. Given sufficient resources, we can guarantee success. For my example this shows the percentage success (i.e. probability of success on any attempt) followed by the price we pay in some monitary units.
Success rate (P) - Cost (C)
20%  -  10
40%  -  20 
60%  -  40
80%  -  80
100% - 160

The example shows that if we pay 10 units we will have a 20% success rate. If we fail, the next time we will pay the same price. We are permitted to retry anytime until we are successful.
I would like to find the most cost-effective solution in terms of expected cost. Is it possible to do that? 
 A: Yes this can be done.  I assume you want to minimize the expected cost when only one fee is paid throughout the sequence of failures.  The probabilities at each time is just the probability that the first success is on trial k and this has the negative binomial distribution I think.  So for each p you can get expected cost by summing over all n, n times the cost c times P{first success is trial n} You only have five expected values to compute and you take the smallest value.
Note that p=1 mean success on the first trial so for that case the cost is 160. You would take that on less oone of the other probabilities have expected cost below this bound of 160.
Just to illustrate how to do the calculation consider p=0.2
You calculate ∑n (0.8)$^n$$^-$$^1$ (0.2)(10)  summing n from 1 to infinity.
You can factor 10(0.2) out of the sum.  The series remaining can be summed using this trick relating it to the geometric series for any choice of p.
∑n p$^n$$^-$$^1$ = ∑ d/dp (p$^n$)= d/dp(∑p$^n$).  Plug in 0.2 for p in this case after calculating the series for any p and differentiating the result with respect to p.
