convolve_cpp returns the convolution of two discrete distributions given
their supports and the corresponding probabilities.
It is not really intended for use with ddf objects but rather for more
general situations.
If you want to convolve two ddf distributions, it is recommended and
certainly more convenient to use conv() instead.
Details
Some assumptions are made for the function to work properly which should be
followed. Most importantly, corresponding numeric vectors (e.g. supp1 and
probs1) should have the same length.
The function returns a list with components "support" and "probabilities" which give the matching attributes of the convolution.
Examples
# Calculate the probability distribution
# of the sum of two six-sided dice
convolve_cpp((1:6), rep(1/6, 6), (1:6), rep(1/6, 6))
#> $support
#> [1] 2 3 4 5 6 7 8 9 10 11 12
#>
#> $probabilities
#> [1] 0.02777778 0.05555556 0.08333333 0.11111111 0.13888889 0.16666667
#> [7] 0.13888889 0.11111111 0.08333333 0.05555556 0.02777778
#>
