gnuplot中的标准化直方图,带有附加函数图

gnuplot中的标准化直方图,带有附加函数图,gnuplot,histogram,Gnuplot,Histogram,我有以下脚本来绘制直方图: 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 -

我有以下脚本来绘制直方图:

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
这应该是一些分布的经验实现,因此,为了更清楚地说明这一点,我想:

  • 适当地规范化条带,以便将其与密度函数进行比较(我猜条带的面积之和应等于单位?这意味着每个条带的高度应除以条带宽度*numberOfElements)
  • 在同一幅图上,理论分布函数由封闭式公式(如高斯)给出

  • 我怎样才能做到这一点?

    我设法解决了这个问题。 (1) 标准化进入冒号后的列,因此plot命令变为:

    plot 'ConfUoMBM1validation0_0.txt' using (rounded($1)):(1/(bin_width*STATS_records)) smooth frequency with boxes lc rgb colour1 notitle
    
    (2) 绘制函数非常简单,只需在昏迷后像通常一样进行即可

    因此,最终结果是:

    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
    
    设置终端postscript eps增强颜色
    设置标题“ConfUoMBM1validation0”
    color1=“#00A0ff”
    color2=“海军”
    color3=“#ffA000”
    color4=“#800000”
    设置输出“ConfUoMBM1validation0\u 0.eps”
    设置样式填充实体0.8边框-1
    箱柜宽度=0.926911
    设置箱宽箱宽
    箱柜编号(x)=楼层(x/箱柜宽度)
    四舍五入(x)=料仓宽度*(料仓编号(x)+0.5)
    invsqrt2pi=0.398942280401433
    标准(x,mu,sigma)=sigma