DistributionsAD.jl icon indicating copy to clipboard operation
DistributionsAD.jl copied to clipboard

StackOverflowError when sampling from mixture model

Open BenjaminJCox opened this issue 2 years ago • 0 comments

MWE:

using Distributions
using DistributionsAD
using Random

test_mm = MixtureModel([TuringDenseMvNormal(randn(10), collect(I(10))) for comp in 1:10])
rand(test_mm)

This type of code comes up as I construct a mixture distribution inside of the function I take the gradient of, so the construction of the mixture must explicitly be these distributions (otherwise one gets covert errors).

I have no idea why this behaviour happens, but it occurs even when only 1 component is in the mixture. For now I can get around it by sampling the vector of distributions then sampling the result, but this is not ideal.

BenjaminJCox avatar Jul 06 '23 02:07 BenjaminJCox