0
$\begingroup$

I'm trying to do the following

Integrate[Exp[-λ] λ^k/k!, {k, 0, ∞}]

The answer should be 1 but Mathematica is unable to do it. Same story when I try the expectation value (answer should be λ)

Integrate[Exp[-λ] λ^k/k!*k, {k, 0, ∞}]

It doesn't even work if I replace λ with a number, say 2.

Any pointers on what I should do to get Mathematica to evaluate?

$\endgroup$
4
  • 3
    $\begingroup$ You don't exactly integrate a discrete distribution, y'know… $\endgroup$ Feb 19, 2016 at 4:12
  • $\begingroup$ How about replacing k! with Gamma[k+1]? That still doesn't work. $\endgroup$ Feb 19, 2016 at 4:19
  • $\begingroup$ It certainly won't. Again, Poisson is a discrete distribution. Integrating is intended for continuous distributions. Replace Integrate[] with Sum[] and report back. $\endgroup$ Feb 19, 2016 at 4:21
  • $\begingroup$ Ah I see your point. If you wanna make your comment an answer, I can accept it. Thanks! $\endgroup$ Feb 19, 2016 at 4:23

1 Answer 1

3
$\begingroup$

k is a discrete random variable, where for this distribution k takes on the the values of the non-negative integers. So you sum over those, as opposed to integrating as you would for a continuous random variable:

In[1]:= Sum[(E^-λ λ^k)/k!, {k, 0, ∞}]

Out[1]= 1
$\endgroup$
3
  • 2
    $\begingroup$ Can you maybe expand on your answer to point out the difference between discrete and continuous distributions? $\endgroup$ Feb 19, 2016 at 4:27
  • $\begingroup$ Looks like you just did in the comments above, but ok. $\endgroup$
    – Mark Adler
    Feb 19, 2016 at 4:36
  • 3
    $\begingroup$ Now I don't have to write an answer, and can just upvote yours instead. Thanks! ;) $\endgroup$ Feb 19, 2016 at 4:38

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