Annotation of OpenXM_contrib/gnuplot/demo/prob.dem, Revision 1.1
1.1 ! maekawa 1: #
! 2: # $Id: prob.dem,v 1.4 1996/12/09 15:58:09 drd Exp $
! 3: #
! 4: # Demo Statistical Functions version 2.3
! 5: #
! 6: # Permission granted to distribute freely for non-commercial purposes only
! 7: #
! 8: # Copyright (c) 1991, 1992 Jos van der Woude, jvdwoude@hut.nl
! 9:
! 10: print " Statistical Library Demo, version 2.3"
! 11: print "\n Copyright (c) 1991, 1992, Jos van de Woude, jvdwoude@hut.nl"
! 12: print "Permission granted to distribute freely for non-commercial purposes only"
! 13: print "\n\n\n\n\n\n\n"
! 14: print "NOTE: contains 54 plots and consequently takes a lot of time to run"
! 15: print " Press Ctrl-C to exit right now"
! 16: pause -1 " Press Return to start demo ..."
! 17:
! 18: load "stat.inc"
! 19:
! 20: # Arcsinus PDF and CDF
! 21: r = 2.0
! 22: mu = 0.0
! 23: sigma = r / sqrt2
! 24: xmin = -r
! 25: xmax = r
! 26: ymax = 1.1 * r #No mode
! 27: set nokey
! 28: set zeroaxis
! 29: set xrange [xmin : xmax]
! 30: set yrange [0 : ymax]
! 31: set xlabel "x ->"
! 32: set ylabel "probability density ->"
! 33: set xtics autofreq
! 34: set ytics autofreq
! 35: set format x "%.1f"
! 36: set format y "%.1f"
! 37: set sample 200
! 38: set title "arcsin PDF with r = 2.0"
! 39: plot arcsin(x)
! 40: pause -1 "Hit return to continue"
! 41: set title "arcsin CDF with r = 2.0"
! 42: set yrange [0 : 1.1]
! 43: plot carcsin(x)
! 44: pause -1 "Hit return to continue"
! 45:
! 46: # Beta PDF and CDF
! 47: #p = 0.5; q = 0.7
! 48: #mu = p / (p + q)
! 49: #sigma = sqrt(p**q) / ((p + q ) * sqrt(p + q + 1.0))
! 50: #xmin = 0.0
! 51: #xmax = 1.0
! 52: #Mode of beta PDF used
! 53: #ymax = (p < 1.0 || q < 1.0) ? 2.0 : 1.1 * beta((p - 1.0)/(p + q - 2.0))
! 54: set key
! 55: set zeroaxis
! 56: #set xrange [xmin : xmax]
! 57: #set yrange [0 : ymax]
! 58: set xlabel "x ->"
! 59: set ylabel "probability density ->"
! 60: set xtics autofreq
! 61: set ytics autofreq
! 62: set format x "%.1f"
! 63: set format y "%.1f"
! 64: set sample 100
! 65: set title "beta PDF"
! 66: plot [0:1] [0:5] p = 0.5, q = 0.7, beta(x) title "p = 0.5, q = 0.7", \
! 67: p = 5.0, q = 3.0, beta(x) title "p = 5.0, q = 3.0", \
! 68: p = 0.5, q = 2.5, beta(x) title "p = 0.5, q = 2.5"
! 69: pause -1 "Hit return to continue"
! 70: set title "incomplete beta CDF"
! 71: plot [0:1] [0:1.1] p = 0.5, q = 0.7, cbeta(x) title "p = 0.5, q = 0.7", \
! 72: p = 5.0, q = 3.0, cbeta(x) title "p = 5.0, q = 3.0", \
! 73: p = 0.5, q = 2.5, cbeta(x) title "p = 0.5, q = 2.5"
! 74: pause -1 "Hit return to continue"
! 75:
! 76: # Binomial PDF and CDF
! 77: n = 25; p = 0.15
! 78: mu = n * p
! 79: sigma = sqrt(n * p * (1.0 - p))
! 80: xmin = int(mu - 4.0 * sigma)
! 81: xmin = xmin < 0 ? 0 : xmin
! 82: xmax = int(mu + 4.0 * sigma)
! 83: ymax = 1.1 * binom(mu) #Mode of normal PDF used
! 84: xinc = ceil((xmax - xmin) / 10)
! 85: xinc = xinc > 1 ? xinc : 1
! 86: set nokey
! 87: set nozeroaxis
! 88: set xrange [xmin : xmax]
! 89: set yrange [0 : ymax]
! 90: set xlabel "k ->"
! 91: set ylabel "probability density ->"
! 92: set xtics xmin + 0.499, xinc, xmax
! 93: set ytics 0, ymax / 10, ymax
! 94: set format x "%2.0f"
! 95: set format y "%3.2f"
! 96: set sample (xmax - xmin) + 1
! 97: set title "binomial PDF with n = 25, p = 0.15"
! 98: plot binom(x) with steps
! 99: pause -1 "Hit return to continue"
! 100: set title "binomial CDF with n = 25, p = 0.15"
! 101: set yrange [0 : 1.1]
! 102: set ytics 0, 1.1 / 10.5, 1.1
! 103: plot cbinom(x) with steps
! 104: pause -1 "Hit return to continue"
! 105:
! 106: # Cauchy PDF and CDF
! 107: #a = 0.0; b = 2.0
! 108: #cauchy PDF has no moments
! 109: #xmin = a - 4.0 * b
! 110: #xmax = a + 4.0 * b
! 111: #ymax = 1.1 * cauchy(a) #Mode of cauchy PDF used
! 112: set key
! 113: set zeroaxis
! 114: #set xrange [xmin : xmax]
! 115: #set yrange [0 : ymax]
! 116: set xlabel "x ->"
! 117: set ylabel "probability density ->"
! 118: set xtics autofreq
! 119: set ytics autofreq
! 120: set format x "%.1f"
! 121: set format y "%.2f"
! 122: set sample 100
! 123: set title "cauchy PDF"
! 124: plot [-15:15] [0:0.2] a = 0, b = 2, cauchy(x) title "a = 0, b = 2", \
! 125: a = 0, b = 4, cauchy(x) title "a = 0, b = 4"
! 126: pause -1 "Hit return to continue"
! 127: set title "cauchy CDF"
! 128: plot [-30:30] [0:1.1] a = 0, b = 2, ccauchy(x) title "a = 0, b = 2", \
! 129: a = 0, b = 4, ccauchy(x) title "a = 0, b = 4"
! 130: pause -1 "Hit return to continue"
! 131:
! 132: # Chi-square PDF and CDF
! 133: #df1 = 4.0
! 134: #mu = df1
! 135: #sigma = sqrt(2.0 * df1)
! 136: #xmin = mu - 4.0 * sigma
! 137: #xmin = xmin < 0 ? 0 : xmin
! 138: #xmax = mu + 4.0 * sigma
! 139: #ymax = 1.1 * (df1 > 2.0 ? chi(df1 - 2.0) : 1.0) #Mode of chi PDF used
! 140: set key
! 141: set zeroaxis
! 142: #set xrange [xmin : xmax]
! 143: #set yrange [0 : ymax]
! 144: set xlabel "x ->"
! 145: set ylabel "probability density ->"
! 146: set xtics autofreq
! 147: set ytics autofreq
! 148: set format x "%.1f"
! 149: set format y "%.2f"
! 150: set sample 100
! 151: set title "chi-square PDF"
! 152: plot [0:15] [0:0.2] df1 = 4, chi(x) title "df = 4", \
! 153: df1 = 6, chi(x) title "df = 6", \
! 154: df1 = 8, chi(x) title "df = 8"
! 155: pause -1 "Hit return to continue"
! 156: set title "chi-square CDF"
! 157: plot [0:15] [0:1.1] df1 = 4, cchi(x) title "df = 4", \
! 158: df1 = 6, cchi(x) title "df = 6", \
! 159: df1 = 8, cchi(x) title "df = 8"
! 160: pause -1 "Hit return to continue"
! 161:
! 162: # Erlang PDF and CDF
! 163: #lambda = 1.0; n = 2.0
! 164: #mu = n / lambda
! 165: #sigma = sqrt(n) / lambda
! 166: #xmin = mu - 4.0 * sigma
! 167: #xmin = xmin < 0 ? 0 : xmin
! 168: #xmax = mu + 4.0 * sigma
! 169: #ymax = n < 2.0 ? 1.0 : 1.1 * erlang((n - 1.0) / lambda) #Mode of erlang PDF used
! 170: set key
! 171: set zeroaxis
! 172: #set xrange [xmin : xmax]
! 173: #set yrange [0 : ymax]
! 174: set xlabel "x ->"
! 175: set ylabel "probability density ->"
! 176: set xtics autofreq
! 177: set ytics autofreq
! 178: set format x "%.1f"
! 179: set format y "%.1f"
! 180: set sample 100
! 181: set title "erlang PDF"
! 182: plot [0:10] [0:1] lambda = 1, n = 2, erlang(x) title "lambda = 1, n = 2", \
! 183: lambda = 2, n = 2, erlang(x) title "lambda = 2, n = 2"
! 184: pause -1 "Hit return to continue"
! 185: set title "erlang CDF"
! 186: plot [0:10] [0:1.1] lambda = 1, n = 2, cerlang(x) title "lambda = 1, n = 2", \
! 187: lambda = 2, n = 2, cerlang(x) title "lambda = 2, n = 2"
! 188: pause -1 "Hit return to continue"
! 189:
! 190: # Thanks to mrb2j@kelvin.seas.Virginia.EDU for telling us about this.
! 191: # Extreme (Gumbel extreme value) PDF and CDF
! 192: #alpha = 0.5; u = 1.0
! 193: #mu = u + (0.577215665/alpha) # Euler's constant
! 194: #sigma = pi/(sqrt(6.0)*alpha)
! 195: #xmin = mu - 4.0 * sigma
! 196: #xmax = mu + 4.0 * sigma
! 197: #ymax = 1.1 * extreme(u) #Mode of extreme PDF used
! 198: set key
! 199: set zeroaxis
! 200: #set xrange [xmin : xmax]
! 201: #set yrange [0 : ymax]
! 202: set xlabel "x ->"
! 203: set ylabel "probability density ->"
! 204: set xtics autofreq
! 205: set ytics autofreq
! 206: set format x "%.1f"
! 207: set format y "%.2f"
! 208: set sample 100
! 209: set title "extreme PDF"
! 210: plot [-10:10] [0:0.4] alpha = 0.5, u = 1.0, extreme(x) title "alpha = 0.5, u = 1.0", \
! 211: alpha = 1.0, u = 0.0, extreme(x) title "alpha = 1.0, u = 0.0"
! 212: pause -1 "Hit return to continue"
! 213: set title "extreme CDF"
! 214: plot [-10:10] [0:1.1] alpha = 0.5, u = 1.0, cextreme(x) title "alpha = 0.5, u = 1.0", \
! 215: alpha = 1.0, u = 0.0, cextreme(x) title "alpha = 1.0, u = 0.0"
! 216: pause -1 "Hit return to continue"
! 217:
! 218: # F PDF and CDF
! 219: #df1 = 5.0; df2 = 9.0
! 220: #mu = df2 < 2.0 ? 1.0 : df2 / (df2 - 2.0)
! 221: #sigma = df2 < 4.0 ? 1.0 : mu * sqrt(2.0 * (df1 + df2 - 2.0) / (df1 * (df2 - 4.0)))
! 222: #xmin = mu - 4.0 * sigma
! 223: #xmin = xmin < 0 ? 0 : xmin
! 224: #xmax = mu + 4.0 * sigma
! 225: #Mode of F PDF used
! 226: #ymax = df1 < 3.0 ? 1.0 : 1.1 * f((df1 / 2.0 - 1.0) / (df1 / 2.0 + df1 / df2))
! 227: set key
! 228: set zeroaxis
! 229: #set xrange [xmin : xmax]
! 230: #set yrange [0 : ymax]
! 231: set xlabel "x ->"
! 232: set ylabel "probability density ->"
! 233: set xtics autofreq
! 234: set ytics autofreq
! 235: set format x "%.1f"
! 236: set format y "%.2f"
! 237: set sample 100
! 238: set title "F PDF"
! 239: plot [0:4] [0:0.8] df1 = 5.0, df2 = 9.0, f(x) title "df1 = 5, df2 = 9", \
! 240: df1 = 7.0, df2 = 6.0, f(x) title "df1 = 7, df2 = 6"
! 241: pause -1 "Hit return to continue"
! 242: set title "F CDF"
! 243: plot [0:4] [0:1.1] df1 = 5.0, df2 = 9.0, cf(x) title "df1 = 5, df2 = 9", \
! 244: df1 = 7.0, df2 = 6.0, cf(x) title "df1 = 7, df2 = 6"
! 245: pause -1 "Hit return to continue"
! 246:
! 247: # Gamma PDF and incomplete gamma CDF
! 248: #rho = 0.5; lambda = 1.0
! 249: #mu = rho / lambda
! 250: #sigma = sqrt(rho) / lambda
! 251: #xmin = mu - 4.0 * sigma
! 252: #xmin = xmin < 0 ? 0 : xmin
! 253: #xmax = mu + 4.0 * sigma
! 254: #ymax = rho < 1.0 ? 2.0 : 1.1 * g((rho - 1.0) / lambda) #Mode of gamma pdf used
! 255: set key
! 256: set zeroaxis
! 257: #set xrange [xmin: xmax]
! 258: #set yrange [0: ymax]
! 259: set xlabel "x ->"
! 260: set ylabel "probability density ->"
! 261: set xtics autofreq
! 262: set ytics autofreq
! 263: set format x "%.1f"
! 264: set format y "%.1f"
! 265: set sample 100
! 266: set title "gamma PDF"
! 267: plot [0:5] [0:1.5] rho = 0.5, lambda = 1.0, g(x) title "rho = 0.5, lambda = 1.0", \
! 268: rho = 1.0, lambda = 1.0, g(x) title "rho = 1.0, lambda = 1.0", \
! 269: rho = 2.0, lambda = 2.0, g(x) title "rho = 2.0, lambda = 2.0"
! 270: pause -1 "Hit return to continue"
! 271: set title "incomplete gamma CDF (lambda == 1.0)"
! 272: plot [0:5] [0:1.1] rho = 0.5, cgamma(x) title "rho = 0.5", \
! 273: rho = 1.0, cgamma(x) title "rho = 1.0", \
! 274: rho = 2.0, cgamma(x) title "rho = 2.0"
! 275: pause -1 "Hit return to continue"
! 276:
! 277: # Geometric PDF and CDF
! 278: p = 0.4
! 279: mu = (1.0 - p) / p
! 280: sigma = sqrt(mu / p)
! 281: xmin = int(mu - 4.0 * sigma)
! 282: xmin = xmin < 0 ? 0 : xmin
! 283: xmax = int(mu + 4.0 * sigma)
! 284: xinc = ceil((xmax - xmin) / 10)
! 285: xinc = xinc > 1 ? xinc : 1
! 286: ymax = 1.1 * geometric(mu - 1/p) #mode of gamma PDF used
! 287: set nokey
! 288: set nozeroaxis
! 289: set xrange [xmin : xmax]
! 290: set yrange [0 : ymax]
! 291: set xlabel "k ->"
! 292: set ylabel "probability density ->"
! 293: set xtics xmin + 0.499, xinc, xmax
! 294: set ytics 0, ymax / 10, ymax
! 295: set format x "%2.0f"
! 296: set format y "%3.2f"
! 297: set sample (xmax - xmin) + 1
! 298: set title "geometric PDF with p = 0.4"
! 299: plot geometric(x) with steps
! 300: pause -1 "Hit return to continue"
! 301: set title "geometric CDF with p = 0.4"
! 302: set yrange [0 : 1.1]
! 303: set ytics 0, 1.1 / 10.5, 1.1
! 304: plot cgeometric(x) with steps
! 305: pause -1 "Hit return to continue"
! 306:
! 307: # Half normal PDF and CDF
! 308: mu = sqrt2invpi
! 309: sigma = 1.0
! 310: s = sigma*sqrt(1.0 - 2.0/pi)
! 311: xmin = 0.0
! 312: xmax = mu + 4.0 * s
! 313: ymax = 1.1 * halfnormal(0) #Mode of half normal PDF used
! 314: set nokey
! 315: set zeroaxis
! 316: set xrange [xmin: xmax]
! 317: set yrange [0: ymax]
! 318: set xlabel "x ->"
! 319: set ylabel "probability density ->"
! 320: set xtics autofreq
! 321: set ytics autofreq
! 322: set format x "%.1f"
! 323: set format y "%.1f"
! 324: set sample 100
! 325: set title "half normal PDF, sigma = 1.0"
! 326: plot halfnormal(x)
! 327: pause -1 "Hit return to continue"
! 328: set title "half normal CDF, sigma = 1.0"
! 329: set yrange [0:1.1]
! 330: plot chalfnormal(x)
! 331: pause -1 "Hit return to continue"
! 332:
! 333: # Hypergeometric PDF and CPF
! 334: nn = 75; mm = 25; n = 10
! 335: p = real(mm) / nn
! 336: mu = n * p
! 337: sigma = sqrt(real(nn - n) / (nn - 1.0) * n * p * (1.0 - p))
! 338: xmin = int(mu - 4.0 * sigma)
! 339: xmin = xmin < 0 ? 0 : xmin
! 340: xmax = int(mu + 4.0 * sigma)
! 341: xinc = ceil((xmax - xmin) / 10)
! 342: xinc = xinc > 1 ? xinc : 1
! 343: ymax = 1.1 * hypgeo(mu) #mode of binomial PDF used
! 344: set nokey
! 345: set nozeroaxis
! 346: set xrange [xmin : xmax]
! 347: set yrange [0 : ymax]
! 348: set xlabel "k ->"
! 349: set ylabel "probability density ->"
! 350: set xtics xmin + 0.499, xinc, xmax
! 351: set ytics 0, ymax / 10, ymax
! 352: set format x "%2.0f"
! 353: set format y "%3.2f"
! 354: set sample (xmax - xmin) + 1
! 355: set title "hypergeometric PDF with nn = 75, mm = 25, n = 10"
! 356: plot hypgeo(x) with steps
! 357: pause -1 "Hit return to continue"
! 358: set yrange [0 : 1.1]
! 359: set ytics 0, 1.1 / 10.5, 1.1
! 360: set title "hypergeometric CDF with nn = 75, mm = 25, n = 10"
! 361: plot chypgeo(x) with steps
! 362: pause -1 "Hit return to continue"
! 363:
! 364: # Laplace PDF
! 365: a = 0.0; b = 1.0
! 366: mu = a
! 367: sigma = sqrt(2.0) * b
! 368: xmin = mu - 4.0 * sigma
! 369: xmax = mu + 4.0 * sigma
! 370: ymax = 1.1 * laplace(a) #Mode of laplace PDF used
! 371: set nokey
! 372: set zeroaxis
! 373: set xrange [xmin: xmax]
! 374: set yrange [0: ymax]
! 375: set xlabel "x ->"
! 376: set ylabel "probability density ->"
! 377: set xtics autofreq
! 378: set ytics autofreq
! 379: set format x "%.1f"
! 380: set format y "%.2f"
! 381: set sample 100
! 382: set title "laplace (or double exponential) PDF with a = 0, b = 1"
! 383: plot laplace(x)
! 384: pause -1 "Hit return to continue"
! 385: set title "laplace (or double exponential) CDF with a = 0, b = 1"
! 386: set yrange [0: 1.1]
! 387: plot claplace(x)
! 388: pause -1 "Hit return to continue"
! 389:
! 390: # Logistic PDF and CDF
! 391: a = 0.0; lambda = 2.0
! 392: mu = a
! 393: sigma = pi / (sqrt(3.0) * lambda)
! 394: xmin = mu - 4.0 * sigma
! 395: xmax = mu + 4.0 * sigma
! 396: ymax = 1.1 * logistic(mu) #Mode of logistic PDF used
! 397: set nokey
! 398: set zeroaxis
! 399: set xrange [xmin: xmax]
! 400: set yrange [0: ymax]
! 401: set nokey
! 402: set zeroaxis
! 403: set xlabel "x ->"
! 404: set ylabel "probability density ->"
! 405: set xtics autofreq
! 406: set ytics autofreq
! 407: set format x "%.1f"
! 408: set format y "%.1f"
! 409: set sample 100
! 410: set title "logistic PDF with a = 0, lambda = 2"
! 411: plot logistic(x)
! 412: pause -1 "Hit return to continue"
! 413: set title "logistic CDF with a = 0, lambda = 2"
! 414: set yrange [0: 1.1]
! 415: plot clogistic(x)
! 416: pause -1 "Hit return to continue"
! 417:
! 418: # Lognormal PDF and CDF
! 419: mu = 1.0; sigma = 0.5
! 420: m = exp(mu + 0.5 * sigma**2)
! 421: s = sqrt(exp(2.0 * mu + sigma**2) * (2.0 * exp(sigma) - 1.0))
! 422: xmin = m - 4.0 * s
! 423: xmin = xmin < 0 ? 0 : xmin
! 424: xmax = m + 4.0 * s
! 425: ymax = 1.1 * lognormal(exp(mu - sigma**2)) #Mode of lognormal PDF used
! 426: set nokey
! 427: set zeroaxis
! 428: set xrange [xmin: xmax]
! 429: set yrange [0: ymax]
! 430: set xlabel "x ->"
! 431: set ylabel "probability density ->"
! 432: set xtics autofreq
! 433: set ytics autofreq
! 434: set format x "%.2f"
! 435: set format y "%.2f"
! 436: set sample 100
! 437: set title "lognormal PDF with mu = 1.0, sigma = 0.5"
! 438: plot lognormal(x)
! 439: pause -1 "Hit return to continue"
! 440: set title "lognormal CDF with mu = 1.0, sigma = 0.5"
! 441: set yrange [0: 1.1]
! 442: plot clognormal(x)
! 443: pause -1 "Hit return to continue"
! 444:
! 445: # Maxwell PDF
! 446: #a = 0.1
! 447: #mu = 2.0 / sqrt(pi) / a
! 448: #sigma = sqrt(3.0 - 8.0/pi) / a
! 449: #xmin = mu - 4.0 * sigma
! 450: #xmin = xmin < 0 ? 0 : xmin
! 451: #xmax = mu + 4.0 * sigma
! 452: #ymax = 1.1 * maxwell(1.0 / a) #Mode of maxwell PDF used
! 453: set key
! 454: set zeroaxis
! 455: #set xrange[xmin: xmax]
! 456: #set yrange[0: ymax]
! 457: set xlabel "x ->"
! 458: set ylabel "probability density ->"
! 459: set xtics autofreq
! 460: set ytics autofreq
! 461: set format x "%.1f"
! 462: set format y "%.1f"
! 463: set sample 100
! 464: set title "maxwell PDF"
! 465: plot [0:6] [0:1.4] a = 1.5, maxwell(x) title "a = 1.5", \
! 466: a = 1.0, maxwell(x) title "a = 1.0", \
! 467: a = 0.5, maxwell(x) title "a = 0.5"
! 468: pause -1 "Hit return to continue"
! 469: set title "maxwell CDF"
! 470: plot [0:6] [0:1.1] a = 1.5, cmaxwell(x) title "a = 1.5", \
! 471: a = 1.0, cmaxwell(x) title "a = 1.0", \
! 472: a = 0.5, cmaxwell(x) title "a = 0.5"
! 473: pause -1 "Hit return to continue"
! 474:
! 475: # Negative binomial PDF and CDF
! 476: r = 8; p = 0.4
! 477: mu = r * (1.0 - p) / p
! 478: sigma = sqrt(mu / p)
! 479: xmin = int(mu - 4.0 * sigma)
! 480: xmin = xmin < 0 ? 0 : xmin
! 481: xmax = int(mu + 4.0 * sigma)
! 482: xinc = ceil((xmax - xmin) / 10)
! 483: xinc = xinc > 1 ? xinc : 1
! 484: ymax = 1.1 * negbin(mu - 1.0/p) #mode of gamma PDF used
! 485: set nokey
! 486: set nozeroaxis
! 487: set xrange [xmin : xmax]
! 488: set yrange [0 : ymax]
! 489: set xlabel "k ->"
! 490: set ylabel "probability density ->"
! 491: set xtics xmin + 0.499, xinc, xmax
! 492: set ytics 0, ymax / 10, ymax
! 493: set format x "%2.0f"
! 494: set format y "%3.2f"
! 495: set sample (xmax - xmin) + 1
! 496: set title "negative binomial (or pascal or polya) PDF with r = 8, p = 0.4"
! 497: plot negbin(x) with steps
! 498: pause -1 "Hit return to continue"
! 499: set yrange [0 : 1.1]
! 500: set ytics 0, 1.1 / 10.5, 1.1
! 501: set title "negative binomial (or pascal or polya) CDF with r = 8, p = 0.4"
! 502: plot cnegbin(x) with steps
! 503: pause -1 "Hit return to continue"
! 504:
! 505: # Negative exponential PDF and CDF
! 506: lambda = 2.0
! 507: mu = 1.0 / lambda
! 508: sigma = 1.0 / lambda
! 509: xmax = mu + 4.0 * sigma
! 510: ymax = lambda #No mode
! 511: set nokey
! 512: set zeroaxis
! 513: set xrange [0: xmax]
! 514: set yrange [0: ymax]
! 515: set xlabel "x ->"
! 516: set ylabel "probability density ->"
! 517: set xtics autofreq
! 518: set ytics autofreq
! 519: set format x "%.2f"
! 520: set format y "%.1f"
! 521: set sample 100
! 522: set title "negative exponential (or exponential) PDF with lambda = 2.0"
! 523: plot nexp(x)
! 524: pause -1 "Hit return to continue"
! 525: set title "negative exponential (or exponential) CDF with lambda = 2.0"
! 526: set yrange [0: 1.1]
! 527: plot cnexp(x)
! 528: pause -1 "Hit return to continue"
! 529:
! 530: # Normal PDF and CDF
! 531: #mu = 0.0; sigma = 1.0
! 532: #xmin = mu - 4.0 * sigma
! 533: #xmax = mu + 4.0 * sigma
! 534: #ymax = 1.1 * normal(mu) #Mode of normal PDF used
! 535: set key
! 536: set zeroaxis
! 537: #set xrange [xmin: xmax]
! 538: #set yrange [0: ymax]
! 539: set xlabel "x ->"
! 540: set ylabel "probability density ->"
! 541: set xtics autofreq
! 542: set ytics autofreq
! 543: set format x "%.1f"
! 544: set format y "%.1f"
! 545: set sample 100
! 546: set title "normal (also called gauss or bell-curved) PDF"
! 547: plot [-4:4] [0:1] mu = 0, sigma = 1.0, normal(x) title "mu = 0, sigma = 1.0", \
! 548: mu = 2, sigma = 0.5, normal(x) title "mu = 2, sigma = 0.5", \
! 549: mu = 1, sigma = 2.0, normal(x) title "mu = 1, sigma = 2.0"
! 550: pause -1 "Hit return to continue"
! 551: set title "normal (also called gauss or bell-curved) CDF"
! 552: plot [-4:4] [0:1.1] mu = 0, sigma = 1.0, cnormal(x) title "mu = 0, sigma = 1.0", \
! 553: mu = 2, sigma = 0.5, cnormal(x) title "mu = 2, sigma = 0.5", \
! 554: mu = 1, sigma = 2.0, cnormal(x) title "mu = 1, sigma = 2.0"
! 555: pause -1 "Hit return to continue"
! 556:
! 557: # Pareto PDF and CDF
! 558: a = 1.0; b = 3.0
! 559: mu = a * b / (b - 1.0)
! 560: sigma = a * sqrt(b) / (sqrt(b - 2.0) * (b - 1.0))
! 561: xmin = mu - 4.0 * sigma
! 562: xmin = xmin < 0 ? 0 : xmin
! 563: xmax = mu + 4.0 * sigma
! 564: ymax = 1.1 * pareto(a) #mode of pareto PDF used
! 565: set nokey
! 566: set zeroaxis
! 567: set xrange [xmin: xmax]
! 568: set yrange [0: ymax]
! 569: set xlabel "x ->"
! 570: set ylabel "probability density ->"
! 571: set xtics autofreq
! 572: set ytics autofreq
! 573: set format x "%.1f"
! 574: set format y "%.1f"
! 575: set sample 500
! 576: set title "pareto PDF with a = 1, b = 3"
! 577: plot pareto(x)
! 578: pause -1 "Hit return to continue"
! 579: set title "pareto CDF with a = 1, b = 3"
! 580: set yrange [0: 1.1]
! 581: plot cpareto(x)
! 582: pause -1 "Hit return to continue"
! 583:
! 584: # Poisson PDF and CDF
! 585: mu = 4.0
! 586: sigma = sqrt(mu)
! 587: xmin = int(mu - 4.0 * sigma)
! 588: xmin = xmin < 0 ? 0 : xmin
! 589: xmax = int(mu + 4.0 * sigma)
! 590: xinc = ceil((xmax - xmin) / 10)
! 591: xinc = xinc > 1 ? xinc : 1
! 592: ymax = 1.1 * poisson(mu) #mode of poisson PDF used
! 593: set nokey
! 594: set nozeroaxis
! 595: set xrange [xmin : xmax]
! 596: set yrange [0 : ymax]
! 597: set xlabel "k ->"
! 598: set ylabel "probability density ->"
! 599: set xtics xmin + 0.499, xinc, xmax
! 600: set ytics 0, ymax / 10, ymax
! 601: set format x "%2.0f"
! 602: set format y "%3.2f"
! 603: set sample (xmax - xmin) + 1
! 604: set title "poisson PDF with mu = 4.0"
! 605: plot poisson(x) with steps
! 606: pause -1 "Hit return to continue"
! 607: set yrange [0 : 1.1]
! 608: set ytics 0, 1.1 / 10.5, 1.1
! 609: set title "poisson CDF with mu = 4.0"
! 610: plot cpoisson(x) with steps
! 611: pause -1 "Hit return to continue"
! 612:
! 613: # Rayleigh PDF and CDF
! 614: lambda = 2.0
! 615: mu = 0.5 * sqrt(pi / lambda)
! 616: sigma = sqrt((1.0 - pi / 4.0) / lambda)
! 617: xmax = mu + 4.0 * sigma
! 618: ymax = 1.1 * rayleigh(1.0 / sqrt(2.0 * lambda)) #Mode of rayleigh PDF used
! 619: set nokey
! 620: set zeroaxis
! 621: set xrange [0: xmax]
! 622: set yrange [0: ymax]
! 623: set xlabel "x ->"
! 624: set ylabel "probability density ->"
! 625: set xtics autofreq
! 626: set ytics autofreq
! 627: set format x "%.2f"
! 628: set format y "%.1f"
! 629: set sample 100
! 630: set title "rayleigh PDF with lambda = 2.0"
! 631: plot rayleigh(x)
! 632: pause -1 "Hit return to continue"
! 633: set title "rayleigh CDF with lambda = 2.0"
! 634: set yrange [0: 1.1]
! 635: plot crayleigh(x)
! 636: pause -1 "Hit return to continue"
! 637:
! 638: # Sine PDF and CDF
! 639: #a = 3.0; n = 2
! 640: #mu = a / 2.0
! 641: #sigma = sqrt(a * a / 3.0 * (1.0 - 3.0 / (2.0 * n * n * pi * pi)) - mu * mu)
! 642: #xmin = 0.0
! 643: #xmax = a
! 644: #ymax = 1.1 * 2.0 / a #Mode of sine PDF used
! 645: set key
! 646: set zeroaxis
! 647: #set xrange [xmin: xmax]
! 648: #set yrange [0: ymax]
! 649: set xlabel "x ->"
! 650: set ylabel "probability density ->"
! 651: set xtics autofreq
! 652: set ytics autofreq
! 653: set format x "%.2f"
! 654: set format y "%.1f"
! 655: set sample 100
! 656: set title "sine PDF"
! 657: plot [0:2] [0:1.1] a = 2.0, n = 1, sine(x) title "a = 2.0, n = 1", \
! 658: a = 2.0, n = 3, sine(x) title "a = 2.0, n = 3"
! 659: pause -1 "Hit return to continue"
! 660: set title "sine CDF"
! 661: plot [0:2] [0:1.1] a = 2.0, n = 1, csine(x) title "a = 2.0, n = 1", \
! 662: a = 2.0, n = 3, csine(x) title "a = 2.0, n = 3"
! 663: pause -1 "Hit return to continue"
! 664:
! 665: # t PDF and CDF
! 666: df1 = 3.0
! 667: mu = 0.0
! 668: sigma = df1 > 2.0 ? sqrt(df1 / (df1 - 2.0)) : 1.0
! 669: xmin = mu - 4.0 * sigma
! 670: xmax = mu + 4.0 * sigma
! 671: ymax = 1.1 * t(mu) #Mode of t PDF used
! 672: set nokey
! 673: set zeroaxis
! 674: set xrange [xmin: xmax]
! 675: set yrange [0: ymax]
! 676: set xlabel "x ->"
! 677: set ylabel "probability density ->"
! 678: set xtics autofreq
! 679: set ytics autofreq
! 680: set format x "%.1f"
! 681: set format y "%.2f"
! 682: set sample 100
! 683: set title "t PDF with df1 = 3.0"
! 684: plot t(x)
! 685: pause -1 "Hit return to continue"
! 686: set title "t CDF with df1 = 3.0"
! 687: set yrange [0: 1.1]
! 688: plot ct(x)
! 689: pause -1 "Hit return to continue"
! 690:
! 691: # Thanks to efrank@upenn5.hep.upenn.edu for telling us about this
! 692: # triangular PDF and CDF
! 693: m = 3.0
! 694: g = 2.0
! 695: mu = m
! 696: sigma = g/sqrt(6.0)
! 697: xmin = m - g
! 698: xmax = m + g
! 699: ymax = 1.1 * triangular(m) #Mode of triangular PDF used
! 700: set nokey
! 701: set zeroaxis
! 702: set xrange [xmin: xmax]
! 703: set yrange [0: ymax]
! 704: set xlabel "x ->"
! 705: set ylabel "probability density ->"
! 706: set xtics autofreq
! 707: set ytics autofreq
! 708: set format x "%.1f"
! 709: set format y "%.2f"
! 710: set sample 100
! 711: set title "triangular PDF with m = 3.0, g = 2.0"
! 712: plot triangular(x)
! 713: pause -1 "Hit return to continue"
! 714: set title "triangular CDF with m = 3.0, g = 2.0"
! 715: set yrange [0: 1.1]
! 716: plot ctriangular(x)
! 717: pause -1 "Hit return to continue"
! 718:
! 719: # Uniform PDF and CDF
! 720: a = -2.0; b= 2.0
! 721: mu = (a + b) / 2.0
! 722: sigma = (b - a) / sqrt(12.0)
! 723: xmin = a
! 724: xmax = b
! 725: ymax = 1.1 * uniform(mu) #No mode
! 726: set nokey
! 727: set zeroaxis
! 728: set xrange [xmin: xmax]
! 729: set yrange [0: ymax]
! 730: set xlabel "x ->"
! 731: set ylabel "probability density ->"
! 732: set xtics autofreq
! 733: set ytics autofreq
! 734: set format x "%.2f"
! 735: set format y "%.2f"
! 736: set sample 100
! 737: set title "uniform PDF with a = -2.0, b = 2.0"
! 738: plot uniform(x)
! 739: pause -1 "Hit return to continue"
! 740: set title "uniform CDF with a = -2.0, b = 2.0"
! 741: set yrange [0: 1.1]
! 742: plot cuniform(x)
! 743: pause -1 "Hit return to continue"
! 744:
! 745: # Weibull PDF and CDF
! 746: #lambda = 1.0; n = 1.5
! 747: #mu = lambda**(-1.0 / n) * gamma(1.0 / n) / n
! 748: #sigma = sqrt(2.0 * lambda**(-2.0 / n) * gamma(2.0 / n) / n - mu * mu)
! 749: #xmin = mu - 4.0 * sigma
! 750: #xmin = xmin < 0 ? 0 : xmin
! 751: #xmax = mu + 4.0 * sigma
! 752: #Mode of weibull PDF used
! 753: #ymax = 1.1 * (n > 1.0 ? weibull(((n - 1.0) / (lambda * n))**(1.0 / n)) : 2.0)
! 754: set key
! 755: set zeroaxis
! 756: #set xrange [xmin : xmax]
! 757: #set yrange [0: ymax]
! 758: set xlabel "x ->"
! 759: set ylabel "probability density ->"
! 760: set xtics autofreq
! 761: set ytics autofreq
! 762: set format x "%.2f"
! 763: set format y "%.1f"
! 764: set sample 100
! 765: set title "weibull PDF"
! 766: plot [0:2] [0:1.5] lambda = 1, n = 0.5, weibull(x) title "lambda = 1, n = 0.5", \
! 767: lambda = 1, n = 1.0, weibull(x) title "lambda = 1, n = 1.0", \
! 768: lambda = 1, n = 2.0, weibull(x) title "lambda = 1, n = 2.0", \
! 769: lambda = 3, n = 2.0, weibull(x) title "lambda = 3, n = 2.0"
! 770: pause -1 "Hit return to continue"
! 771: set title "weibull CDF"
! 772: plot [0:3] [0:1.2] lambda = 1, n = 0.5, cweibull(x) title "lambda = 1, n = 0.5", \
! 773: lambda = 1, n = 1.0, cweibull(x) title "lambda = 1, n = 1.0", \
! 774: lambda = 1, n = 2.0, cweibull(x) title "lambda = 1, n = 2.0", \
! 775: lambda = 3, n = 2.0, cweibull(x) title "lambda = 3, n = 2.0"
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>