JuliaPlots / StatsPlots.jl

Statistical plotting recipes for Plots.jl
Other
437 stars 88 forks source link

Support plotting any UnivariateMixture #456

Closed sethaxen closed 3 years ago

sethaxen commented 3 years ago

Generalizes code for plotting MixtureModel to plotting UnivariateMixture. Fixes #448.

Example

julia> d = MixtureModel([Normal(0, 1), Normal(4, 2)], [0.2, 0.8])
MixtureModel{Normal{Float64}}(K = 2)
components[1] (prior = 0.2000): Normal{Float64}(μ=0.0, σ=1.0)
components[2] (prior = 0.8000): Normal{Float64}(μ=4.0, σ=2.0)

julia> d2 = UnivariateGMM([0, 4], [1, 2], Categorical([0.2, 0.8]))
UnivariateGMM{Vector{Int64}, Vector{Int64}, Categorical{Float64, Vector{Float64}}}(
K: 2
means: [0, 4]
stds: [1, 2]
prior: Categorical{Float64, Vector{Float64}}(support=Base.OneTo(2), p=[0.2, 0.8])
)

julia> plot(plot(d), plot(d2))

tmp