0

ヒストグラムをプロットする次のスクリプトがあります。

set terminal postscript eps enhanced color
set title "Histogram\_CreatesFile"

colour1="#00A0ff"
colour2="navy"
colour3="#ffA000"
colour4="#800000"
set output 'Histogram_CreatesFile.eps'
set yrange [0:]
set style fill solid 0.8 border -1
bin_width = 0.2
set boxwidth bin_width
bin_number(x) = floor(x/bin_width)
rounded(x) = bin_width * ( bin_number(x) + 0.5 )
plot 'Histogram_CreatesFile.txt' using (rounded($1)):(1) smooth frequency with boxes lc rgb colour1 notitle

これは、いくつかの分布の経験的な実現であると想定されているため、より明確にするために、次のことを行います。

  1. バーを適切に正規化して、密度関数と比較できるようにします (バーの面積の合計は 1 になるはずだと思いますか?それは、各バーの高さを barWidth*numberOfElements で割る必要があることを意味します)。
  2. 同じ図上に、閉じた形式の式 (ガウスなど) で与えられる理論上の分布関数をプロットします。

どうすればこれを達成できますか?

4

1 に答える 1

0

私はこの問題を解決することができました。(1) 正規化はコロンの後の列に入るので、プロット コマンドは次のようになります。

plot 'ConfUoMBM1validation0_0.txt' using (rounded($1)):(1/(bin_width*STATS_records)) smooth frequency with boxes lc rgb colour1 notitle

(2) 関数のプロットは非常に簡単です。通常のように、coma の後に実行してください。

したがって、最終的な結果は次のとおりです。

set terminal postscript eps enhanced color
set title "ConfUoMBM1validation0 0"

colour1="#00A0ff"
colour2="navy"
colour3="#ffA000"
colour4="#800000"
set output 'ConfUoMBM1validation0_0.eps'
set style fill solid 0.8 border -1
bin_width = 0.926911
set boxwidth bin_width
bin_number(x) = floor(x/bin_width)
rounded(x) = bin_width * ( bin_number(x) + 0.5 )
invsqrt2pi = 0.398942280401433
normal(x,mu,sigma)=sigma<=0?1/0:invsqrt2pi/sigma*exp(-0.5*((x-mu)/sigma)**2)
stats 'ConfUoMBM1validation0_0.txt' using (rounded($1)) nooutput
set xrange [STATS_min-bin_width/2.:STATS_max+bin_width/2.]
set yrange [0:]
plot 'ConfUoMBM1validation0_0.txt' using (rounded($1)):(1/(bin_width*STATS_records)) smooth frequency with boxes lc rgb colour1 notitle, normal(x,-0.14166974006432781,4.6345562297659741) with lines lc rgb colour2 lw 5 notitle
于 2013-05-31T15:48:51.943 に答える