using Random, Distributions
using CairoMakie, ColorSchemes
using DataFrames
fig = Figure()
for (i, n) in enumerate([60, 600, 6_000, 60_000])
r, c = divrem(i-1, 2) # 2行2列のグリッドのr行c列目
data = rand(1:6, n) # 1から6までの整数をn個生成
ax = Axis(fig[r + 1, c + 1],
xticks = 1:6,
yticks = ([0, 0.1, 0.16666, 0.2], ["0", "0.1", "1/6", "0.2"]),
title = "n = $n",
xlabel = L"x",
ylabel = L"P(X=x)"
)
hist!(ax, data,
bins = [0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5], # ビンの左端
normalization = :probability, # 相対度数で規格化
strokewidth = 1, strokecolor = :black,color=:orange
)
x = [0.5, 6.5]
lines!(ax, x, [1/6 for _ in x], color = :black, linewidth = 2, linestyle = :dash)
ylims!(ax, 0, 0.25)
end
save("dist-diceroll.svg", fig)
fig