UncertaintyQuantification.jl icon indicating copy to clipboard operation
UncertaintyQuantification.jl copied to clipboard

Interface for joint distributions

Open FriesischScott opened this issue 1 year ago • 7 comments

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

FriesischScott avatar Oct 07 '24 13:10 FriesischScott

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).

AnderGray avatar Oct 07 '24 13:10 AnderGray

For sliced normals, we might be able to use transport maps from @jgrashorn

AnderGray avatar Oct 07 '24 13:10 AnderGray

For sliced normals, we might be able to use transport maps from @jgrashorn

I'll believe that when I see it :D

FriesischScott avatar Oct 07 '24 13:10 FriesischScott

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.

FriesischScott avatar Oct 07 '24 13:10 FriesischScott

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.

AnderGray avatar Oct 07 '24 13:10 AnderGray

I'll make this happen once I'm done with the rosenblatt transformation in Copulas.jl and we can add it as a dependency.

FriesischScott avatar Feb 28 '25 12:02 FriesischScott

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.

FriesischScott avatar Apr 01 '25 07:04 FriesischScott

I think we have two base cases we need to support:

  1. Any MultivariateDistribution implementing the correct Distributions.jl interface. In this case we need a Vector{Symbol} for the names. This would also support SlicedDistributions.jl
  2. A Copula in which case we need a Vector{RandomVariables}. These could then also be pboxes if 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.

FriesischScott avatar Jul 16 '25 12:07 FriesischScott