I am trying to understand the purpose of convolution of two probability functions. Also when it is appropriate to use the convolve function on two independent probability distributions.
VariableOne = {
1: 0.5,
3: 0.5
}
VariableTwo = {
7: 0.5,
8: 0.5
}
Meaning that the probability of getting either 1 or 3 is 0.5 and probability of getting either 7 or 8 is 0.5.
Now looking at wikipedia I quote The probability distribution of the sum of two or more independent random variables is the convolution of their individual distributions. However, when running the following in R:
convolve(c(0.5, 0.5), rev(c(0.5, 0.5)), type="o")
I get
0.25 0.50 0.25
But I would expect to get 4 values one for each of the following combinations:
{
1+7 : p1,
1+8 : p2,
3+7 : p3,
3+8 : p4
}
Update
However it works if I have
VariableOne = {
1: 0.4,
2: 0.6
}
VariableTwo = {
1: 0.3,
2: 0.7
}
If I run the following in R:
convolve(c(0.4, 0.6), rev(c(0.3, 0.7)), type="o")
Giving
0.12 0.46 0.42
This makes sense because I can do this which gives the correct probabilities
{
1+1 : 0.12,
1+2, 2+1: 0.46,
2+2 : 0.42
}
Obviously my understanding is missing something, any help appreciated.
You have the correct values for the sum. Also, it is easy to see (multiplication rule for independent events) that each of them has probability 1/4.
A simulation in R, confirms this (only approximately, of course):
I have not used the 'convolve' function enough to be sure of an example of that. Maybe you can figure it out.
I'm not sure whether the assignment was to do the convolution by hand from theory (almost trivial), specifically to use 'convolve' in R, or to get the answer by any means possible.
Anyhow, I hope this helps.