0

I'm quite stuck at the moment with a little function I write. I want to embed the following function into my program:

where is the convolution of of the cumulative distribution function of a poisson distribution.

If I got it right, I'd calculate the convolution like this, where k is the number of events in an interval, Mu is just the mean e.g. 5 and j is the number of convolutions:

from scipy.stats import poisson
poisson.cdf(k, (Mu * (1 + i)))

The function D looks like this:

which is done in python like this:

def D(k, y, i):
    y = y - k
    return (2 * max(0, y) - 10 min(0, y)) * poisson.cdf(k, (Mu * (1 + i)))

Now the tricky part where I'm stuck is, how to get the integral to work with the cdf. Currently I'm trying to do it like this but I don't have a clue how to continue:

from scipy.integrate import quad
def Integrate(i, y):
    return quad(D, 0, np.inf, args=(y, i))[0]

If anyone has an idea how to do that, I'd really appreciate it :)

Edit: To check whether the convolution of the cdf is correct, I did this:

print(poisson.pmf(0,(Mu * (1 + i))) + poisson.pmf(1,(Mu * (1 + i))))
>>> 0.445679641365
print(poisson.cdf(1,(Mu * (1 + i))))
>>> 0.445679641365
Community
  • 1
  • 1
FriendlyGuy
  • 331
  • 5
  • 14
  • The function D has subscript n but it's not used anywhere. Also, the convolution of CDFs is not the CDF of the sum of random variables. Rather, the convolution of PDFs is the PDF of the sum. To convert all PDFs to CDFs, one has to integrate n times (n being the number of variables). The first integration changes PDF of the sum to the CDF of the sum, but then there are (n-1) integrations left. –  Dec 01 '16 at 18:32
  • @zaq Sorry for my late reply, I was rather busy the last days. – FriendlyGuy Dec 07 '16 at 14:11
  • I did a bit of trial and error and figured out that the convolution, at least of the poisson distribution, of the CDF is indeed the sum of the RVs as shown in my edit or have I done something wrong there? I'm not that familiar with convolutions unfortunately. And for the subscript, the n is not so important but the difference between n -i and n --> i is. – FriendlyGuy Dec 07 '16 at 14:18
  • Never mind, I found another solution to my problem :) – FriendlyGuy Dec 07 '16 at 16:03

0 Answers0