|
| 1 | +import Distributions: |
| 2 | + |
| 3 | +""" |
| 4 | +A named distribution that carries the name of the random variable with it. |
| 5 | +""" |
| 6 | +struct NamedDist{ |
| 7 | + variate, |
| 8 | + support, |
| 9 | + Td <: Distribution{variate, support}, |
| 10 | + Tn |
| 11 | +} <: Distribution{variate, support} |
| 12 | + dist::Td |
| 13 | + name::Tn |
| 14 | +end |
| 15 | + |
| 16 | + |
| 17 | +struct NoDist{ |
| 18 | + variate, |
| 19 | + support, |
| 20 | + Td <: Distribution{variate, support} |
| 21 | +} <: Distribution{variate, support} |
| 22 | + dist::Td |
| 23 | +end |
| 24 | +NoDist(dist::NamedDist) = NamedDist(NoDist(dist.dist), dist.name) |
| 25 | + |
| 26 | +Distributions.rand(d::NoDist) = rand(d.dist) |
| 27 | +Distributions.logpdf(d::NoDist{<:Univariate}, ::Real) = 0 |
| 28 | +Distributions.logpdf(d::NoDist{<:Multivariate}, ::AbstractVector{<:Real}) = 0 |
| 29 | +function Distributions.logpdf(d::NoDist{<:Multivariate}, x::AbstractMatrix{<:Real}) |
| 30 | + return zeros(Int, size(x, 2)) |
| 31 | +end |
| 32 | +Distributions.logpdf(d::NoDist{<:Matrixvariate}, ::AbstractMatrix{<:Real}) = 0 |
| 33 | +Bijectors.logpdf_with_trans(d::NoDist{<:Univariate}, ::Real) = 0 |
| 34 | +Bijectors.logpdf_with_trans(d::NoDist{<:Multivariate}, ::AbstractVector{<:Real}) = 0 |
| 35 | +function Bijectors.logpdf_with_trans(d::NoDist{<:Multivariate}, x::AbstractMatrix{<:Real}) |
| 36 | + return zeros(Int, size(x, 2)) |
| 37 | +end |
| 38 | +Bijectors.logpdf_with_trans(d::NoDist{<:Matrixvariate}, ::AbstractMatrix{<:Real}) = 0 |
0 commit comments