KeyedDistributions.jl

Distributions and Sampleables with keys for the variates
Author invenia
Popularity
0 Stars
Updated Last
1 Year Ago
Started In
March 2021

KeyedDistributions

Stable Dev Build Status Coverage Code Style: Blue ColPrac: Contributor's Guide on Collaborative Practices for Community Packages

KeyedDistributions.jl provides thin wrappers of Distribution and Sampleable, to store keys for the variates.

julia> using KeyedDistributions, Distributions;

julia> kd = KeyedDistribution(MvNormal(3, 1.0), [:x, :y, :z]);

julia> axiskeys(kd)
([:x, :y, :z],)

julia> distribution(kd)
ZeroMeanIsoNormal(
dim: 3
μ: 3-element Zeros{Float64}
Σ: [1.0 0.0 0.0; 0.0 1.0 0.0; 0.0 0.0 1.0]
)

Methods for Distribution and Sampleable return KeyedArrays in place of regular Arrays, where applicable.

julia> mean(kd)
1-dimensional KeyedArray(...) with keys:3-element Vector{Symbol}
And data, 3-element Zeros{Float64}:
 (:x)  0.0
 (:y)  0.0
 (:z)  0.0
 
julia> rand(kd, 2)
2-dimensional KeyedArray(...) with keys:3-element Vector{Symbol}
→   2-element OneTo{Int}
And data, 3×2 Matrix{Float64}:
        (1)           (2)
  (:x)   -1.11227      -0.279841
  (:y)    0.00784496    0.871718
  (:z)   -0.930186     -0.8922

In this way, KeyedDistributions.jl extends the AxisKeys ecosystem to Distributions.jl.

Used By Packages

No packages found.