📄 prob.dem
字号:
# Logistic PDF and CDFa = 0.0; lambda = 2.0mu = asigma = pi / (sqrt(3.0) * lambda)xmin = mu - 4.0 * sigmaxmax = mu + 4.0 * sigmaymax = 1.1 * logistic(mu) #Mode of logistic PDF usedunset keyset zeroaxisset xrange [xmin: xmax]set yrange [0: ymax]unset keyset zeroaxisset xlabel "x ->"set ylabel "probability density ->"set xtics autofreqset ytics autofreqset format x "%.1f"set format y "%.1f"set sample 100set title "logistic PDF with a = 0, lambda = 2"plot logistic(x)pause -1 "Hit return to continue"set title "logistic CDF with a = 0, lambda = 2"set yrange [0: 1.1]plot clogistic(x)pause -1 "Hit return to continue"# Lognormal PDF and CDFmu = 1.0; sigma = 0.5m = exp(mu + 0.5 * sigma**2)s = sqrt(exp(2.0 * mu + sigma**2) * (2.0 * exp(sigma) - 1.0))xmin = m - 4.0 * sxmin = xmin < 0 ? 0 : xminxmax = m + 4.0 * symax = 1.1 * lognormal(exp(mu - sigma**2)) #Mode of lognormal 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 "%.2f"set format y "%.2f"set sample 100set title "lognormal PDF with mu = 1.0, sigma = 0.5"plot lognormal(x)pause -1 "Hit return to continue"set title "lognormal CDF with mu = 1.0, sigma = 0.5"set yrange [0: 1.1]plot clognormal(x)pause -1 "Hit return to continue"# Maxwell PDF#a = 0.1#mu = 2.0 / sqrt(pi) / a#sigma = sqrt(3.0 - 8.0/pi) / a#xmin = mu - 4.0 * sigma#xmin = xmin < 0 ? 0 : xmin#xmax = mu + 4.0 * sigma#ymax = 1.1 * maxwell(1.0 / a) #Mode of maxwell 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 "maxwell PDF"set key right top boxplot [0:6] [0:1.4] a = 1.5, maxwell(x) title "a = 1.5", \ a = 1.0, maxwell(x) title "a = 1.0", \ a = 0.5, maxwell(x) title "a = 0.5"pause -1 "Hit return to continue"set title "maxwell CDF"set key right bottom boxplot [0:6] [0:1.1] a = 1.5, cmaxwell(x) title "a = 1.5", \ a = 1.0, cmaxwell(x) title "a = 1.0", \ a = 0.5, cmaxwell(x) title "a = 0.5"pause -1 "Hit return to continue"# Negative binomial PDF and CDFr = 8; p = 0.4mu = r * (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 * negbin(mu - 1.0/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 "negative binomial (or pascal or polya) PDF with r = 8, p = 0.4"plot negbin(x) with stepspause -1 "Hit return to continue"set yrange [0 : 1.1]set ytics 0, 1.1 / 10.5, 1.1set title "negative binomial (or pascal or polya) CDF with r = 8, p = 0.4"plot cnegbin(x) with stepspause -1 "Hit return to continue"# Negative exponential PDF and CDFlambda = 2.0mu = 1.0 / lambdasigma = 1.0 / lambdaxmax = mu + 4.0 * sigmaymax = lambda #No modeunset keyset zeroaxisset xrange [0: xmax]set yrange [0: ymax]set xlabel "x ->"set ylabel "probability density ->"set xtics autofreqset ytics autofreqset format x "%.2f"set format y "%.1f"set sample 100set title "negative exponential (or exponential) PDF with lambda = 2.0"plot nexp(x)pause -1 "Hit return to continue"set title "negative exponential (or exponential) CDF with lambda = 2.0"set yrange [0: 1.1]plot cnexp(x)pause -1 "Hit return to continue"# Normal PDF and CDF#mu = 0.0; sigma = 1.0#xmin = mu - 4.0 * sigma#xmax = mu + 4.0 * sigma#ymax = 1.1 * normal(mu) #Mode of normal 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 "normal (also called gauss or bell-curved) PDF"set key left top boxplot [-4:4] [0:1] mu = 0, sigma = 1.0, normal(x) title "mu = 0, sigma = 1.0", \ mu = 2, sigma = 0.5, normal(x) title "mu = 2, sigma = 0.5", \ mu = 1, sigma = 2.0, normal(x) title "mu = 1, sigma = 2.0"pause -1 "Hit return to continue"set title "normal (also called gauss or bell-curved) CDF"set key left top boxplot [-4:4] [0:1.1] mu = 0, sigma = 1.0, cnormal(x) title "mu = 0, sigma = 1.0", \ mu = 2, sigma = 0.5, cnormal(x) title "mu = 2, sigma = 0.5", \ mu = 1, sigma = 2.0, cnormal(x) title "mu = 1, sigma = 2.0"pause -1 "Hit return to continue"# Pareto PDF and CDFa = 1.0; b = 3.0mu = a * b / (b - 1.0)sigma = a * sqrt(b) / (sqrt(b - 2.0) * (b - 1.0))xmin = mu - 4.0 * sigmaxmin = xmin < 0 ? 0 : xminxmax = mu + 4.0 * sigmaymax = 1.1 * pareto(a) #mode of pareto 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 500set title "pareto PDF with a = 1, b = 3"plot pareto(x)pause -1 "Hit return to continue"set title "pareto CDF with a = 1, b = 3"set yrange [0: 1.1]plot cpareto(x)pause -1 "Hit return to continue"# Poisson PDF and CDFmu = 4.0sigma = sqrt(mu)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 * poisson(mu) #mode of poisson 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 "poisson PDF with mu = 4.0"plot poisson(x) with stepspause -1 "Hit return to continue"set yrange [0 : 1.1]set ytics 0, 1.1 / 10.5, 1.1set title "poisson CDF with mu = 4.0"plot cpoisson(x) with stepspause -1 "Hit return to continue"# Rayleigh PDF and CDFlambda = 2.0mu = 0.5 * sqrt(pi / lambda)sigma = sqrt((1.0 - pi / 4.0) / lambda)xmax = mu + 4.0 * sigmaymax = 1.1 * rayleigh(1.0 / sqrt(2.0 * lambda)) #Mode of rayleigh PDF usedunset keyset zeroaxisset xrange [0: xmax]set yrange [0: ymax]set xlabel "x ->"set ylabel "probability density ->"set xtics autofreqset ytics autofreqset format x "%.2f"set format y "%.1f"set sample 100set title "rayleigh PDF with lambda = 2.0"plot rayleigh(x)pause -1 "Hit return to continue"set title "rayleigh CDF with lambda = 2.0"set yrange [0: 1.1]plot crayleigh(x)pause -1 "Hit return to continue"# Sine PDF and CDF#a = 3.0; n = 2#mu = a / 2.0#sigma = sqrt(a * a / 3.0 * (1.0 - 3.0 / (2.0 * n * n * pi * pi)) - mu * mu)#xmin = 0.0#xmax = a#ymax = 1.1 * 2.0 / a #Mode of sine 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 "%.2f"set format y "%.1f"set sample 100set title "sine PDF"set key bottom outsideplot [0:2] [0:1.1] a = 2.0, n = 1, sine(x) title "a = 2.0, n = 1", \ a = 2.0, n = 3, sine(x) title "a = 2.0, n = 3"pause -1 "Hit return to continue"set title "sine CDF"set key top leftplot [0:2] [0:1.1] a = 2.0, n = 1, csine(x) title "a = 2.0, n = 1", \ a = 2.0, n = 3, csine(x) title "a = 2.0, n = 3"pause -1 "Hit return to continue"# t PDF and CDFdf1 = 3.0mu = 0.0sigma = df1 > 2.0 ? sqrt(df1 / (df1 - 2.0)) : 1.0xmin = mu - 4.0 * sigmaxmax = mu + 4.0 * sigmaymax = 1.1 * t(mu) #Mode of t 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 "t PDF with df1 = 3.0"plot t(x)pause -1 "Hit return to continue"set title "t CDF with df1 = 3.0"set yrange [0: 1.1]plot ct(x)pause -1 "Hit return to continue"# Thanks to efrank@upenn5.hep.upenn.edu for telling us about this# triangular PDF and CDFm = 3.0g = 2.0mu = msigma = g/sqrt(6.0)xmin = m - gxmax = m + gymax = 1.1 * triangular(m) #Mode of triangular 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 "triangular PDF with m = 3.0, g = 2.0"plot triangular(x)pause -1 "Hit return to continue"set title "triangular CDF with m = 3.0, g = 2.0"set yrange [0: 1.1]plot ctriangular(x)pause -1 "Hit return to continue"# Uniform PDF and CDFa = -2.0; b= 2.0mu = (a + b) / 2.0sigma = (b - a) / sqrt(12.0)xmin = axmax = bymax = 1.1 * uniform(mu) #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 "%.2f"set format y "%.2f"set sample 100set title "uniform PDF with a = -2.0, b = 2.0"plot uniform(x)pause -1 "Hit return to continue"set title "uniform CDF with a = -2.0, b = 2.0"set yrange [0: 1.1]plot cuniform(x)pause -1 "Hit return to continue"# Weibull PDF and CDF#lambda = 1.0; n = 1.5#mu = lambda**(-1.0 / n) * gamma(1.0 / n) / n#sigma = sqrt(2.0 * lambda**(-2.0 / n) * gamma(2.0 / n) / n - mu * mu)#xmin = mu - 4.0 * sigma#xmin = xmin < 0 ? 0 : xmin#xmax = mu + 4.0 * sigma#Mode of weibull PDF used#ymax = 1.1 * (n > 1.0 ? weibull(((n - 1.0) / (lambda * n))**(1.0 / n)) : 2.0)set key onset zeroaxis#set xrange [xmin : xmax]#set yrange [0: ymax]set xlabel "x ->"set ylabel "probability density ->"set xtics autofreqset ytics autofreqset format x "%.2f"set format y "%.1f"set sample 100set title "weibull PDF"plot [0:2] [0:1.5] lambda = 1, n = 0.5, weibull(x) title "lambda = 1, n = 0.5", \ lambda = 1, n = 1.0, weibull(x) title "lambda = 1, n = 1.0", \ lambda = 1, n = 2.0, weibull(x) title "lambda = 1, n = 2.0", \ lambda = 3, n = 2.0, weibull(x) title "lambda = 3, n = 2.0"pause -1 "Hit return to continue"set title "weibull CDF"plot [0:3] [0:1.2] lambda = 1, n = 0.5, cweibull(x) title "lambda = 1, n = 0.5", \ lambda = 1, n = 1.0, cweibull(x) title "lambda = 1, n = 1.0", \ lambda = 1, n = 2.0, cweibull(x) title "lambda = 1, n = 2.0", \ lambda = 3, n = 2.0, cweibull(x) title "lambda = 3, n = 2.0"pause -1 "Hit return to continue"reset
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -