invenia / invenia/KeyedDistributions.jl
Add `marginalize` method for certain distributions
- Dominant language
- Julia
- Stars
- 4
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
For `Distribution`s in the exponential family, e.g. `MvNormal` and `GenericMvTDist`, the marginal can be computed simply by dropping the parameters of the marginalised variates ([Wikipedia](https://en.wikipedia.org/wiki/Multivariate_normal_distribution#Marginal_distributions)).
So we can add a `marginalize` method for these cases which uses the lookup syntax (#3) under the hood. This would just be for clarity.
MWE:
```julia
julia> m = KeyedArray([0.1, 0.2, 0.3], [:a, :b, :c]);
julia> d = MvNormal(m);
julia> kd = KeyedDistribution(d)
julia> marginalize(kd, [:a, :c])
KeyedDistribution{Multivariate,Continuous,MvNormal{Float64,PDMats.PDiagMat{Float64,Array{Float64,1}},KeyedArray{Float64,1,Array{Float64,1},Base.RefValue{Array{Symbol,1}}}}}(
d: MvNormal{Float64,PDMats.PDiagMat{Float64,Array{Float64,1}},KeyedArray{Float64,1,Array{Float64,1},Base.RefValue{Array{Symbol,1}}}}(
dim: 2
μ: [0.1, 0.3]
Σ: [1.0 0.0; 0.0 1.0]
)
keys: [:a, :c]
)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.