1
$\begingroup$

I have

pr[x_] := PDF[PoissonDistribution[2], x]

and

Overage[x_] := Sum[(d - x)*pr[d], {d, x, Infinity}]

I would like to have Mathematica try simplify this. If not possible, it should at least keep it the same. However,

Refine[Overage[z], Assumptions -> z >= 0 && z \[Element] Integers]

yields errors "Power::infy: Infinite expression 1/0 encountered." and "Infinity::indet: Indeterminate expression (0 ComplexInfinity)/E^2 encountered.".

This is because it uses the gamma function at some point. I can even pinpoint the issue to z==0.

However, for z==0, the expression is just Overage[0] which is well-defined.

What am I doing wrong here?

$\endgroup$
2
  • $\begingroup$ @BobHanlon Even if d does not start at 0? $\endgroup$
    – IceFire
    Jun 28 '18 at 13:58
  • $\begingroup$ You can manually subtract the finite part, Expectation[...] - Sum[..., {d, 0, x}]. $\endgroup$ Jun 28 '18 at 14:03
1
$\begingroup$

You can get rid of the warnings by using the following:

pr[x_] := Exp[-2] 2^x/x!
Overage[x_] := Sum[(d - x)*pr[d], {d, x, Infinity}]
f[z_] := Refine[Overage[z], 
  Assumptions -> z >= 0 && z \[Element] Integers]
f[z]

$$\frac{2^z \left(e^2 \left(-2^{-z}\right) z+e^2 2^{1-z}+\frac{2}{\Gamma (z+1)}+\frac{e^2 2^{-z} \Gamma (z+1,2)}{\Gamma (z)}-\frac{e^2 2^{1-z} \Gamma (z+1,2)}{\Gamma (z+1)}\right)}{e^2}$$

But if you can ignore the warnings and define

f[z_] := Refine[Overage[z], Assumptions -> z >= 0 && z \[Element] Integers]

then the function works as expected/desired

f[z]

$$\begin{array}{cc} \{ & \begin{array}{cc} -\frac{-2^{z+1} \Gamma (z)-2 e^2 \Gamma (z+1) \Gamma (z)+e^2 z \Gamma (z+1) \Gamma (z)+2 e^2 \Gamma (z) \Gamma (z+1,2)-e^2 \Gamma (z+1) \Gamma (z+1,2)}{e^2 \Gamma (z) \Gamma (z+1)} & z>0 \\ \text{Indeterminate} & \text{True} \\ \end{array} \\ \end{array}$$

f[0]
(* 2 *)

f[3]

$$\frac{9-e^2}{e^2}$$

$\endgroup$
5
  • $\begingroup$ Thank you! Can I somehow eliminate the Gamma functions? If z is integer, I do not need it, I would suppose. But even without Gamma or !, the whole expression seems unnecessary complicated $\endgroup$
    – IceFire
    Jun 28 '18 at 14:08
  • $\begingroup$ Simplicity is in the eye of the beholder. You could replace the Gamma[z] values with (z-1)! using f[z_] := Refine[Overage[z], Assumptions -> z >= 0 && z \[Element] Integers] /. Gamma[x_] -> (x - 1)!. There's not much of any simplification for the incomplete gamma: Gamma[z+1,2]. $\endgroup$
    – JimB
    Jun 28 '18 at 14:36
  • $\begingroup$ I would prefer, though, to have my original pr function used instead of the clumsy long form $\endgroup$
    – IceFire
    Jun 28 '18 at 14:42
  • $\begingroup$ Then keep the original pr function. As stated above all you have to do is ignore the warnings. The original function performs fine. It just gives some warnings. You can suppress the warnings by using the Quiet function. (Exp[-2] 2^x/x! is a "clumsy long form" compared to PDF[PoissonDistribution[2], x] ?? I agree that using PDF is more natural and the desired function to use. $\endgroup$
    – JimB
    Jun 28 '18 at 15:07
  • $\begingroup$ yes, PDF is easier to read, but also using my first pr function yields quite a messy expression because PoissonDistribution will be evaluated immediately $\endgroup$
    – IceFire
    Jun 28 '18 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.