算額あれこれ

算額問題をコンピュータで解きます

Julia に翻訳--232 ヒストグラム

#==========
Julia の修行をするときに,いろいろなプログラムを書き換えるのは有効な方法だ。
以下のプログラムを Julia に翻訳してみる。

ヒストグラム
https://oku.edu.mie-u.ac.jp/~okumura/python/hist.html

ファイル名: ヒストグラム.jl  関数名:

翻訳するときに書いたメモ

統計学においては最も基本的なグラフの一つである。それが故,「○○で描かれるヒストグラムはかっこ悪い」,「描くのが面倒だ」という批判もされやすい。
Julia で,まずまずのヒストグラムが描けただろうか?

==========#

using Plots
pyplot(grid=false, label="")

x = randn(1234);

histogram(x, tick_direction=:out)

histogram(x, color="lightgray", tick_direction=:out)

縦軸を何にするか,Julia では 4 通りある。

normalize: Bool or Symbol. Histogram normalization mode.
Possible values are:
    false/:none (no normalization, default),
    true/:pdf (normalize to a discrete Probability Density Function,
              
where the total area of the bins is 1),
    :probability (bin heights sum to 1) and
    :density (the area of each bin, rather than the height,
              is equal to the counts - useful for uneven bin sizes).

histogram(x, tick_direction=:out, bg=:bisque, grid=true,
    fg_color_grid=:green,
ylabel="Frequency")

histogram(x, normalize=:pdf, ylabel="Pdf", tick_direction=:out,

    bg=:bisque, grid=true, fg_color_grid=:green)
savefig("histogram.png")


histogram(x, normalize=:probability, ylabel="Probability",      
         
tick_direction=:out,
          bg=:bisque, grid=true, fg_color_grid=:green)