我正在学习如何在gnuplot中绘制pdf。代码来自 http://gnuplot.sourceforge.net/demo/random.html
代码是
unset contour
unset parametric
load "stat.inc"
print ""
print "Simple Monte Carlo simulation"
print ""
print "The first curve is a histogram where the binned frequency of occurence"
print "of a pseudo random variable distributed according to the normal"
print "(Gaussian) law is scaled such that the histogram converges to the"
print "normal probability density function with increasing number of samples"
print "used in the Monte Carlo simulation. The second curve is the normal"
print "probability density function with unit variance and zero mean."
print ""
nsamp = 5000
binwidth = 20
xlow = -3.0
xhigh = 3.0
scale = (binwidth/(xhigh-xlow))
# Generate N random data points.
set print "random.tmp"
do for [i=1:nsamp] {
print sprintf("%8.5g %8.5g", invnorm(rand(0)), (1.0*scale/nsamp))
}
unset print
#
set samples 200
tstring(n) = sprintf("Histogram of %d random samples from a univariate\nGaussian PDF with unit variance and zero mean", n)
set title tstring(nsamp)
set key
set grid
set terminal png
set output "x.png"
set xrange [-3:3]
set yrange [0:0.45]
bin(x) = (1.0/scale)*floor(x*scale)
plot "random.tmp" using (bin($1)):2 smooth frequency with steps title "scaled bin frequency", normal(x,0,1) with lines title "Gaussian p.d.f."
我收到错误
Cannot open load file 'stat.inc'
"stat.inc", line 4: util.c: No such file or directory
我使用的gnuplot版本是gnuplot 4.6 patchlevel 0。 请帮助,因为我无法找到此特定文件或在ubuntu平台上运行代码。