I have a probability mass function that should sum to unity algebraically, but neither FullSimplify
nor FunctionExpand
can deal with the Hypergeometric2F1
therein.
myPMF[x_, p_, k_] := ( p^k *(1 - p)^(x - k)
+ (1 - p)^k * p^(x - k) ) Binomial[ x - 1, k - 1] // Simplify
(* coin toss that ends when either k heads or k tails appears ;
x = total number of flips;
k <= x <= 2 k
*)
Assuming[ 0 < p < 1, Element[x | n, Integers]
Sum[ myPMF[x, p, n], {x, n, 2 n - 1}] // FullSimplify
] (* expecting exact 1 like the numerical verification below ;
FunctionExpand basically does nothing to HyperGeometric *)
start = 16; stop = 40; (* this takes maybe 6 seconds *)
Table[
Sum[ myPMF[x, p, n], {x, n, 2 n - 1} ]
, {n, start, stop} ] // Simplify
The exact sum can be done with partial numerical inputs as the code shows.
How do I carry out the algebraic sum and arrive at unity? Perhaps a different way of using FunctionExpand
?
Thank you.
2 - (BetaRegularized[1 - p, n, n] + BetaRegularized[p, n, n])
. $\endgroup$