Interface for joint distributions
We need a general interface for various joint distributions. I think a parameterized struct could work well here. In this we can wrap for example SklarDist from Copulas.jl, MvNormal from Distributions.jl and Sliced Normals/Exponentials.
struct JointDistribution{T} <:RandomUQInput begin
dist::T
names::Vector{Symbol}
This would allow us to define mappings for dispatch for distinct types.
function to_standard_normal_space!(JointDistribution{MvNormal}, df::DataFrame)
...
end
function to_standard_normal_space!(JointDistribution{SlicedNormal}, df::DataFrame)
error("SlicedNormals can not be mapped to standard normal space.")
end
Yes, sounds good. We could alternatively think about decomposing the joints into a copula + marginals if we know it has a closed form (e.g. Normal).
For sliced normals, we might be able to use transport maps from @jgrashorn
For sliced normals, we might be able to use transport maps from @jgrashorn
I'll believe that when I see it :D
Yes, sounds good. We could alternatively think about decomposing the joints into a copula + marginals if we know it has a closed form (e.g. Normal).
For the MvNormal that should work. Not sure how well it generalizes for other mulivariate distributions.
For sliced normals, we might be able to use transport maps from @jgrashorn
I'll believe that when I see it :D
It should be possible, it's a polynomial mapping from SNS to some other distribution of the same dimensions. I think you fit them by minimising some divergence (KL-divergence?). So if we can compute the KL divergence between the sliced normal and some other distribution, should be possible.
But I think you can fit the TM directly to a dataset, so it might be better to just do that. And it can also be the case that the sliced normal is more flexible than the TMs.
I'll make this happen once I'm done with the rosenblatt transformation in Copulas.jl and we can add it as a dependency.
With SlicedDistributions now Distributions.jl compliant the resulting distributions are a ContinuousMultivariateDistribution. We can have a general implementation for these and be more specific in case the transport maps work out.
I think we have two base cases we need to support:
- Any
MultivariateDistributionimplementing the correct Distributions.jl interface. In this case we need aVector{Symbol}for the names. This would also support SlicedDistributions.jl - A
Copulain which case we need aVector{RandomVariables}. These could then also bepboxesif we merge #248 .
So basically something like
struct JointDsitribution
d::Union{MultiVariateDistribution, Copula}
m::Vector{<:Union{Symbol,RandomVariable}}
with one constructor for each case to make sure we always pass the matching inputs.