using Distributions, GLMakie, Random, Pipe
Random.seed!(232)
# 1. define params array
vecs = [[0.1,0.1,0.1],[0.2,0.2,0.2],[1, 1, 1], [2, 2, 2], [6, 6, 6], [10, 10, 10],[20,20,20],[50,50,50],[100,100,100]]
#2. sampling
samples = @pipe vecs |> Dirichlet.(_) |> rand.(_, 1000)
#3. plot
function plot_res()
fig = Figure(resolution=(900,900))
axs = [Axis3(fig[i, j];azimuth=0.2pi) for i in 1:3, j in 1:3]
for (ax, sa,vec) in zip(axs, samples,vecs)
ax.title="$vec"
lines!(ax, [1, 0, 0,1], [0, 1, 0,0], [0, 0, 1,0];color=(:lightgreen,0.5),linewidth=3)
scatter!(ax, eachrow(sa)...; markersize=4, color=(:orange, 0.8))
end
fig
end
plot_res()
1 Like
Another View
using Distributions, GLMakie, Random, Pipe
vecs = [[0.1, 0.1, 0.1], [0.2, 0.2, 0.2], [1, 1, 1], [2, 2, 2], [6, 6, 6], [10, 10, 10], [20, 20, 20], [50, 50, 50], [100, 100, 100]]
sas = @pipe vecs |> Dirichlet.(_) |> rand.(_, 1000)
function plot_res()
fig = Figure(resolution=(900, 900))
axs = [Axis3(fig[i, j]; elevation=0.15pi, azimuth=0.25pi) for i in 1:3, j in 1:3]
for (ax, sa, vec) in zip(axs, sas, vecs)
ax.title = "$vec"
lines!(ax, [1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], color=(:lightgreen, 0.4),linewidth=4)
scatter!(ax, eachrow(sa)...; markersize=6, color=(:orange, 0.8))
hidedecorations!(ax)
hidespines!(ax)
end
fig
end
fig=plot_res();save("./imgs/dirichlet-dist2.png",fig)