How to model Zero Inflated Distribution

Hi. How to programing a Zero Inflated Distribution using Turing?

Without implementing a custom distribution, this is currently only possible for discrete distributions. e.g.

julia> using Distributions, StatsPlots

julia> ZeroInflated(dist, pzero) = MixtureModel([Dirac(0), dist], [pzero, 1 - pzero]);

julia> d = ZeroInflated(Poisson(10), 0.1)
MixtureModel{Distribution{Univariate, Discrete}}(K = 2)
components[1] (prior = 0.1000): Dirac{Int64}(value=0)
components[2] (prior = 0.9000): Poisson{Float64}(λ=10.0)

julia> plot(d; components=false, legend=false)

probability mass function of a zero-inflated Poisson distribution

The reason this currently doesn’t work for continuous distributions is that MixtureModel only supports mixtures of discrete or mixtures of continuous distributions, but not mixtures of both discrete and continuous.

To give concrete suggestions for the continuous case, I would need to know how you are planning to use this zero-inflated distribution in your model.

Thanks!