Open krishvishal opened 2 years ago
Since mixture of Dirichilet distributions lives on a simplex, so its bijector has to be a SimplexBijector.
I've defined a custom distribution with a SimplexBijector to solve this error. Similarly one can define a custom distribution with IdentityBijector for mixture of MvNormal distributions.
using Bijectors, Turing, Distributions, Random
struct CustomMixture <: ContinuousMultivariateDistribution
a::Vector{Float64}
b::Vector{Float64}
weights::Vector{Float64}
end
function Base.rand(rng::Random.AbstractRNG, d::CustomMixture)
sample = rand(rng, MixtureModel(Dirichlet, [d.a, d.b], d.weights))
return sample
end
function Distributions.logpdf(d::CustomMixture, x::AbstractVector)
return logpdf(MixtureModel(Dirichlet, [d.a, d.b], d.weights), x)
end
Base.length(d::CustomMixture) = length(d.a)
Bijectors.bijector(d::CustomMixture) = Bijectors.SimplexBijector{1}()
MWE:
Error:
It seems the bijector for Multivariate MixtureModel is not defined. Can someone please clarify this?