# Convolution of two independent geometric random variables with parameters $p$ and $q$ [closed]

I am trying to use Mathematica to do some computations in Advanced Probability. I am quite new to Mathematica, so I need help in understanding the Convolve function. I used Mathematica 11 to compute the convolution of two independent geometric random variables with parameters p and q respectively, I don't seem to get a closed form expression for the convolution. Here is what I have attempted:

Convolve[PDF[GeometricDistribution[p], k],
PDF[GeometricDistribution[q], k], k - n, n]


The output is:

 Convolve[\[Piecewise]  (1-p)^k p   k>=0
0   True

,\[Piecewise]   (1-q)^k q   k>=0
0   True

,k-n,n].


I further tried to get the same result using the Transformed distribution as follows:

f[x_] = PDF[GeometricDistribution[p], k];
g[y_] = PDF[GeometricDistribution[q], k];
PDF[
TransformedDistribution[
x + y,
{
x \[Distributed] ProbabilityDistribution[f[x], {x, 0, k}],
y \[Distributed] ProbabilityDistribution[g[x], {y, 0, k}]
}
], x
]


I got the output as :

\[Piecewise]    k (1-p)^k p (1-q)^k q   k>0&&2 k-x==0
(1-p)^k p (1-q)^k q (2 k-x) k>0&&k-x<0&&2 k-x>0
(1-p)^k p (1-q)^k q x   k>0&&x>0&&k-x>=0
0   True


I am new to Mathematica so could anyone help me understand what is happening with the two codes above?

• The syntax is: Convolve[PDF[GeometricDistribution[p], k], PDF[GeometricDistribution[q], k], k, n] Nov 29 '21 at 12:18
• @DanielHuber: This produces Piecewise[{{(p*((1 - p)^n - (1 - q)^n)*q)/ (Log[1 - p] - Log[1 - q]), n > 0}}, 0] . Summarizing it by n from 0 to Infinity. one obtains (-p + q)/(Log[1 - p] - Log[1 - q]) instead of 1. Also in the case p==q Convolve produces Piecewise[{{n*(1 - p)^n*p^2, n > 0}}, 0] instead of Piecewise[{{(1 + n)*(1 - p)^n*p^2, n >= 0}}, 0] (see Wiki). If I am not mistaken, it looks like a bug in Convolve. Nov 29 '21 at 14:56

GeometricDistribution is a discrete distribution. Because of it, DiscreteConvolve should be applied:

DiscreteConvolve[PDF[GeometricDistribution[p], k],PDF[GeometricDistribution[q], k], k, n]


Piecewise[{{(p*q*(-(1 - p)^n + (1 - p)^n*p + (1 - q)^n - (1 - q)^n*q))/(p - q), n >= 0}}, 0]

To verify it

Sum[(p*q*(-(1 - p)^n + (1 - p)^n*p + (1 - q)^n - (1 - q)^n*q))/(p -
q), {n, 0, Infinity}, Assumptions -> {p, q} > 0 && {p, q} < 1]


1

• +1 Use FullSimplify to get a simpler form. For completeness you should also look at Limit[conv, p -> q] Nov 30 '21 at 2:40