Closed mirkoklukas closed 1 year ago
Example.
Code below throws MethodError: no method matching HeterogeneousMixture(::Vector{DistributionsBacked})
.
using .GenDistributions
using Distributions
using Gen
const dirichlet = DistributionsBacked(alpha -> Dirichlet(alpha), (true,), true, Vector{Float64})
const flip = DistributionsBacked(p -> Bernoulli(p), (true,), false, Bool)
mix = HeterogeneousMixture([dirichlet,flip])
Gen's
HeterogeneousMixture
expectsVector{Distribution{T}}
and doesn't know what to do withVector{D}
whereD
"inherits" fromDistribution{T}
. Note that feeding[uniform, normal]
is fine since it is converted to the common "supertype" and is treated asVector{Distribution{T}}
. However[D(),D()]
is treated asVector{D}
.This is an issue when you use GenDistributions.jl's
DistributionsBacked
or myPushForward
type for instance.The signature should be changed as follows: