⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prob.dem

📁 智能画图软件
💻 DEM
📖 第 1 页 / 共 2 页
字号:
## $Id: prob.dem,v 1.8 2004/02/14 03:14:43 sfeam Exp $## Demo Statistical Functions version 2.3## Copyright (c) 1991, 1992 Jos van der Woude, jvdwoude@hut.nlprint "                   Statistical Library Demo, version 2.3"print "\n          Copyright (c) 1991, 1992, Jos van de Woude, jvdwoude@hut.nl"print "\n\n\n\n\n\n\n"print "NOTE: contains 54 plots and consequently takes a lot of time to run"print "                      Press Ctrl-C to exit right now"pause -1 "                      Press Return to start demo ..."load "stat.inc"# Arcsinus PDF and CDFr = 2.0mu = 0.0sigma = r / sqrt2xmin = -rxmax = rymax = 1.1 * r #No modeunset keyset zeroaxisset xrange [xmin : xmax]set yrange [0 : ymax]set xlabel "x ->"set ylabel "probability density ->"set xtics autofreqset ytics autofreqset format x "%.1f"set format y "%.1f"set sample 200set title "arcsin PDF with r = 2.0"plot arcsin(x)pause -1 "Hit return to continue"set title "arcsin CDF with r = 2.0"set yrange [0 : 1.1]plot carcsin(x)pause -1 "Hit return to continue"# Beta PDF and CDF#p = 0.5; q = 0.7#mu = p / (p + q)#sigma = sqrt(p**q) / ((p + q ) * sqrt(p + q + 1.0))#xmin = 0.0#xmax = 1.0#Mode of beta PDF used#ymax = (p < 1.0 || q < 1.0) ? 2.0 : 1.1 * beta((p - 1.0)/(p + q - 2.0))set key right boxset zeroaxis#set xrange [xmin : xmax]#set yrange [0 : ymax]set xlabel "x ->"set ylabel "probability density ->"set xtics autofreqset ytics autofreqset format x "%.1f"set format y "%.1f"set sample 100set title "beta PDF"plot [0:1] [0:5] p = 0.5, q = 0.7, beta(x) title "p = 0.5, q = 0.7", \                 p = 5.0, q = 3.0, beta(x) title "p = 5.0, q = 3.0", \                 p = 0.5, q = 2.5, beta(x) title "p = 0.5, q = 2.5"pause -1 "Hit return to continue"set title "incomplete beta CDF"set key left boxplot [0:1] [0:1.1] p = 0.5, q = 0.7, cbeta(x) title "p = 0.5, q = 0.7", \                   p = 5.0, q = 3.0, cbeta(x) title "p = 5.0, q = 3.0", \                   p = 0.5, q = 2.5, cbeta(x) title "p = 0.5, q = 2.5"pause -1 "Hit return to continue"# Binomial PDF and CDFn = 25; p = 0.15mu = n * psigma = sqrt(n * p * (1.0 - p))xmin = int(mu - 4.0 * sigma)xmin = xmin < 0 ? 0 : xminxmax = int(mu + 4.0 * sigma)ymax = 1.1 * binom(mu) #Mode of normal PDF usedxinc = ceil((xmax - xmin) / 10)xinc = xinc > 1 ? xinc : 1unset keyunset zeroaxisset xrange [xmin : xmax]set yrange [0 : ymax]set xlabel "k ->"set ylabel "probability density ->"set xtics xmin + 0.499, xinc, xmaxset ytics 0, ymax / 10, ymaxset format x "%2.0f"set format y "%3.2f"set sample (xmax - xmin) + 1set title "binomial PDF with n = 25, p = 0.15"plot binom(x) with stepspause -1 "Hit return to continue"set title "binomial CDF with n = 25, p = 0.15"set yrange [0 : 1.1]set ytics 0, 1.1 / 10.5, 1.1plot cbinom(x) with stepspause -1 "Hit return to continue"# Cauchy PDF and CDF#a = 0.0; b = 2.0#cauchy PDF has no moments#xmin = a - 4.0 * b#xmax = a + 4.0 * b#ymax = 1.1 * cauchy(a) #Mode of cauchy PDF usedset key left boxset zeroaxis#set xrange [xmin : xmax]#set yrange [0 : ymax]set xlabel "x ->"set ylabel "probability density ->"set xtics autofreqset ytics autofreqset format x "%.1f"set format y "%.2f"set sample 100set title "cauchy PDF"plot [-15:15] [0:0.2] a = 0, b = 2, cauchy(x) title "a = 0, b = 2", \                      a = 0, b = 4, cauchy(x) title "a = 0, b = 4"pause -1 "Hit return to continue"set title "cauchy CDF"plot [-30:30] [0:1.1] a = 0, b = 2, ccauchy(x) title "a = 0, b = 2", \                      a = 0, b = 4, ccauchy(x) title "a = 0, b = 4"pause -1 "Hit return to continue"# Chi-square PDF and CDF#df1 = 4.0#mu = df1#sigma = sqrt(2.0 * df1)#xmin = mu - 4.0 * sigma#xmin = xmin < 0 ? 0 : xmin#xmax = mu + 4.0 * sigma#ymax = 1.1 * (df1 > 2.0 ? chi(df1 - 2.0) : 1.0) #Mode of chi PDF usedset key right boxset zeroaxis#set xrange [xmin : xmax]#set yrange [0 : ymax]set xlabel "x ->"set ylabel "probability density ->"set xtics autofreqset ytics autofreqset format x "%.1f"set format y "%.2f"set sample 100set title "chi-square PDF"set key right boxplot [0:15] [0:0.2] df1 = 4, chi(x) title "df = 4", \                    df1 = 6, chi(x) title "df = 6", \                    df1 = 8, chi(x) title "df = 8"pause -1 "Hit return to continue"set key left boxset title "chi-square CDF"plot [0:15] [0:1.1] df1 = 4, cchi(x) title "df = 4", \                    df1 = 6, cchi(x) title "df = 6", \                    df1 = 8, cchi(x) title "df = 8"pause -1 "Hit return to continue"# Erlang PDF and CDF#lambda = 1.0; n = 2.0#mu = n / lambda#sigma = sqrt(n) / lambda#xmin = mu - 4.0 * sigma#xmin = xmin < 0 ? 0 : xmin#xmax = mu + 4.0 * sigma#ymax = n < 2.0 ? 1.0 : 1.1 * erlang((n - 1.0) / lambda) #Mode of erlang PDF usedset zeroaxis#set xrange [xmin : xmax]#set yrange [0 : ymax]set xlabel "x ->"set ylabel "probability density ->"set xtics autofreqset ytics autofreqset format x "%.1f"set format y "%.1f"set sample 100set title "erlang PDF"set key right boxplot [0:10] [0:1] lambda = 1, n = 2, erlang(x) title "lambda = 1, n = 2", \                  lambda = 2, n = 2, erlang(x) title "lambda = 2, n = 2"pause -1 "Hit return to continue"set title "erlang CDF"set key left boxplot [0:10] [0:1.1] lambda = 1, n = 2, cerlang(x) title "lambda = 1, n = 2", \                    lambda = 2, n = 2, cerlang(x) title "lambda = 2, n = 2"pause -1 "Hit return to continue"# Thanks to mrb2j@kelvin.seas.Virginia.EDU for telling us about this.# Extreme (Gumbel extreme value) PDF and CDF#alpha = 0.5; u = 1.0#mu = u + (0.577215665/alpha)   # Euler's constant#sigma = pi/(sqrt(6.0)*alpha)#xmin = mu - 4.0 * sigma#xmax = mu + 4.0 * sigma#ymax = 1.1 * extreme(u) #Mode of extreme PDF usedset zeroaxis#set xrange [xmin : xmax]#set yrange [0 : ymax]set xlabel "x ->"set ylabel "probability density ->"set xtics autofreqset ytics autofreqset format x "%.1f"set format y "%.2f"set sample 100set title "extreme PDF"set key left boxplot [-10:10] [0:0.4] alpha = 0.5, u = 1.0, extreme(x) title "alpha = 0.5, u = 1.0", \                      alpha = 1.0, u = 0.0, extreme(x) title "alpha = 1.0, u = 0.0"pause -1 "Hit return to continue"set title "extreme CDF"set key left boxplot [-10:10] [0:1.1] alpha = 0.5, u = 1.0, cextreme(x) title "alpha = 0.5, u = 1.0", \                      alpha = 1.0, u = 0.0, cextreme(x) title "alpha = 1.0, u = 0.0"pause -1 "Hit return to continue"# F PDF and CDF#df1 = 5.0; df2 = 9.0#mu = df2 < 2.0 ? 1.0 : df2 / (df2 - 2.0)#sigma = df2 < 4.0 ? 1.0 : mu * sqrt(2.0 * (df1 + df2 - 2.0) / (df1 * (df2 - 4.0)))#xmin = mu - 4.0 * sigma#xmin = xmin < 0 ? 0 : xmin#xmax = mu + 4.0 * sigma#Mode of F PDF used#ymax = df1 < 3.0 ? 1.0 : 1.1 * f((df1 / 2.0 - 1.0) / (df1 / 2.0 + df1 / df2))set zeroaxis#set xrange [xmin : xmax]#set yrange [0 : ymax]set xlabel "x ->"set ylabel "probability density ->"set xtics autofreqset ytics autofreqset format x "%.1f"set format y "%.2f"set sample 100set title "F PDF"set key right boxplot [0:4] [0:0.8] df1 = 5.0, df2 = 9.0, f(x) title "df1 = 5, df2 = 9", \                   df1 = 7.0, df2 = 6.0, f(x) title "df1 = 7, df2 = 6"pause -1 "Hit return to continue"set title "F CDF"set key left boxplot [0:4] [0:1.1] df1 = 5.0, df2 = 9.0, cf(x) title "df1 = 5, df2 = 9", \                   df1 = 7.0, df2 = 6.0, cf(x) title "df1 = 7, df2 = 6"pause -1 "Hit return to continue"# Gamma PDF and incomplete gamma CDF#rho = 0.5; lambda = 1.0#mu = rho / lambda#sigma = sqrt(rho) / lambda#xmin = mu - 4.0 * sigma#xmin = xmin < 0 ? 0 : xmin#xmax = mu + 4.0 * sigma#ymax = rho < 1.0 ? 2.0 : 1.1 * g((rho - 1.0) / lambda) #Mode of gamma pdf usedset zeroaxis#set xrange [xmin: xmax]#set yrange [0: ymax]set xlabel "x ->"set ylabel "probability density ->"set xtics autofreqset ytics autofreqset format x "%.1f"set format y "%.1f"set sample 100set title "gamma PDF"set key rightplot [0:5] [0:1.5] rho = 0.5, lambda = 1.0, g(x) title "rho = 0.5, lambda = 1.0", \                   rho = 1.0, lambda = 1.0, g(x) title "rho = 1.0, lambda = 1.0", \                   rho = 2.0, lambda = 2.0, g(x) title "rho = 2.0, lambda = 2.0"pause -1 "Hit return to continue"set title "incomplete gamma CDF (lambda == 1.0)"set key right bottomplot [0:5] [0:1.1] rho = 0.5, cgamma(x) title "rho = 0.5", \                   rho = 1.0, cgamma(x) title "rho = 1.0", \                   rho = 2.0, cgamma(x) title "rho = 2.0"pause -1 "Hit return to continue"# Geometric PDF and CDFp = 0.4mu = (1.0 - p) / psigma = sqrt(mu / p)xmin = int(mu - 4.0 * sigma)xmin = xmin < 0 ? 0 : xminxmax = int(mu + 4.0 * sigma)xinc = ceil((xmax - xmin) / 10)xinc = xinc > 1 ? xinc : 1ymax = 1.1 * geometric(mu - 1/p) #mode of gamma PDF usedunset keyunset zeroaxisset xrange [xmin : xmax]set yrange [0 : ymax]set xlabel "k ->"set ylabel "probability density ->"set xtics xmin + 0.499, xinc, xmaxset ytics 0, ymax / 10, ymaxset format x "%2.0f"set format y "%3.2f"set sample (xmax - xmin) + 1set title "geometric PDF with p = 0.4"plot geometric(x) with stepspause -1 "Hit return to continue"set title "geometric CDF with p = 0.4"set yrange [0 : 1.1]set ytics 0, 1.1 / 10.5, 1.1plot cgeometric(x) with stepspause -1 "Hit return to continue"# Half normal PDF and CDFmu = sqrt2invpisigma = 1.0s = sigma*sqrt(1.0 - 2.0/pi)xmin = 0.0xmax = mu + 4.0 * symax = 1.1 * halfnormal(0) #Mode of half normal PDF usedunset keyset zeroaxisset xrange [xmin: xmax]set yrange [0: ymax]set xlabel "x ->"set ylabel "probability density ->"set xtics autofreqset ytics autofreqset format x "%.1f"set format y "%.1f"set sample 100set title "half normal PDF, sigma = 1.0"plot halfnormal(x)pause -1 "Hit return to continue"set title "half normal CDF, sigma = 1.0"set yrange [0:1.1]plot chalfnormal(x)pause -1 "Hit return to continue"# Hypergeometric PDF and CPFnn = 75; mm = 25; n = 10p = real(mm) / nnmu = n * psigma = sqrt(real(nn - n) / (nn - 1.0) * n * p * (1.0 - p))xmin = int(mu - 4.0 * sigma)xmin = xmin < 0 ? 0 : xminxmax = int(mu + 4.0 * sigma)xinc = ceil((xmax - xmin) / 10)xinc = xinc > 1 ? xinc : 1ymax = 1.1 * hypgeo(mu) #mode of binomial PDF usedunset keyunset zeroaxisset xrange [xmin : xmax]set yrange [0 : ymax]set xlabel "k ->"set ylabel "probability density ->"set xtics xmin + 0.499, xinc, xmaxset ytics 0, ymax / 10, ymaxset format x "%2.0f"set format y "%3.2f"set sample (xmax - xmin) + 1set title "hypergeometric PDF with nn = 75, mm = 25, n = 10"plot hypgeo(x) with stepspause -1 "Hit return to continue"set yrange [0 : 1.1]set ytics 0, 1.1 / 10.5, 1.1set title "hypergeometric CDF with nn = 75, mm = 25, n = 10"plot chypgeo(x) with stepspause -1 "Hit return to continue"# Laplace PDFa = 0.0; b = 1.0mu = asigma = sqrt(2.0) * bxmin = mu - 4.0 * sigmaxmax = mu + 4.0 * sigmaymax = 1.1 * laplace(a) #Mode of laplace PDF usedunset keyset zeroaxisset xrange [xmin: xmax]set yrange [0: ymax]set xlabel "x ->"set ylabel "probability density ->"set xtics autofreqset ytics autofreqset format x "%.1f"set format y "%.2f"set sample 100set title "laplace (or double exponential) PDF with a = 0, b = 1"plot laplace(x)pause -1 "Hit return to continue"set title "laplace (or double exponential) CDF with a = 0, b = 1"set yrange [0: 1.1]plot claplace(x)pause -1 "Hit return to continue"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -