You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import Distributions: convolve, MixtureModel
# special case: https://mathoverflow.net/questions/370982/convolution-of-two-gaussian-mixture-model
Distributions.convolve(d1::MixtureModel,d2::Normal) =MixtureModel([convolve(c,d2) for c in d1.components],d1.prior)
Distributions.convolve(d1::Normal,d2::MixtureModel) =convolve(d2,d1)
d3 =convolve(d1,d2)
using Test
@testvar(d3.components[1]) ≈2@testvar(d3.components[2]) ≈2@testmean(d3.components[1]) ≈-2@testmean(d3.components[2]) ≈2@testconvolve(d1,d2) ==convolve(d2,d1)
I can easily made a PR with the test case.
The text was updated successfully, but these errors were encountered:
This doesn't necessarily need to be limited to a mixture of Gaussians and a Gaussian, right? It seems like it could generalize to any instance where you have a mixture where all of input models or mixture model components are of the same type, for example:
Distributions.convolve(d1::MixtureModel,d2::MixtureModel) =
MixtureModel([convolve(a,b) for a in d1.components for b in d2.components],[a.*b for a in d1.prior.p for b in d2.prior.p])
Edit 2:
Although this particular example with Gamma won't work due to the arg checking when convolving Gammas, but I think the general idea still holds.
It would be nice to allow the convolution between Gaussian mixture model and normal distribution, for example:
Currently, this fails with:
Support for this would be quite easy to add:
I can easily made a PR with the test case.
The text was updated successfully, but these errors were encountered: