### B.11 Probability and cumulative density functions

The following two tables describe statements that are used to evaluate probability density/mass and cumulative density functions (pdfs and cdfs) of some popular distributions.

 Syntax Mathematical expression Arguments and return values W = betapdf(X, alpha, beta); W = betacdf(X, alpha, beta); $f\left(x\right)=\frac{{x}^{\alpha -1}\cdot {\left(1-x\right)}^{\beta -1}}{B\left(\alpha ,\beta \right)}$ $F\left(x\right)=\frac{\underset{0}{\overset{x}{\int }}{t}^{\alpha -1}\cdot {\left(1-t\right)}^{\beta -1}\phantom{\rule{0.3em}{0ex}}\mathrm{d}t}{B\left(\alpha ,\beta \right)}$ W is a matrix with dimensions equal to those of X and entries equal to the pdf/cdf of the beta distribution with shape parameters alpha and beta, evaluated at each entry of X. The function works element-wise. X must be a matrix or dataset with entries between zero and one If X contains negative entries or entries above one an error is produced alpha must be a positive number beta must be a positive number W = chi2pdf(X, p); W = chi2cdf(X, p); $f\left(x\right)=\frac{{x}^{\frac{p}{2}-1}\cdot {e}^{-\frac{x}{2}}}{{2}^{\frac{p}{2}}\cdot \Gamma \left(\frac{p}{2}\right)}$ $F\left(x\right)=\frac{\underset{0}{\overset{x}{\int }}{t}^{\frac{p}{2}-1}\cdot {e}^{-\frac{t}{2}}\phantom{\rule{0.3em}{0ex}}\mathrm{d}t}{{2}^{\frac{p}{2}}\cdot \Gamma \left(\frac{p}{2}\right)}$ W is a matrix with dimensions equal to those of X and entries equal to the pdf/cdf of the chi-squared distribution with p degrees of freedom, evaluated at each entry of X. The function works element-wise. X must be a matrix or dataset with non-negative entries If X contains negative entries an error is produced p must be a positive number W = exppdf(X, lambda); W = expcdf(X, lambda); $f\left(x\right)=\lambda {e}^{-\lambda x}$ $F\left(x\right)=1-{e}^{-\lambda x}$ W is a matrix with dimensions equal to those of X and entries equal to the pdf/cdf of the exponential distribution with rate parameter lambda, evaluated at each entry of X. The function works element-wise. X must be a matrix or dataset with non-negative entries If X contains negative entries an error is produced lambda must be a positive number W = evpdf(X, mu, sigma); W = evcdf(X, mu, sigma); $f\left(x\right)=\frac{1}{\sigma }exp\left\{-z-{e}^{-z}\right\}$ $F\left(x\right)=exp\left\{-{e}^{-z}\right\}$ where: $z=\frac{x-\mu }{\sigma }$ W is a matrix with dimensions equal to those of X and entries equal to the pdf/cdf of the type-I extreme-value distribution with location parameter mu and scale parameter sigma, evaluated at each entry of X. The function works element-wise. X must be a matrix or dataset mu must be a number sigma must be a positive number W = fpdf(X, p1, p2); W = fcdf(X, p1, p2); $f\left(x\right)=\frac{{\left(\frac{{\left({p}_{1}x\right)}^{{p}_{1}}{p}_{2}^{{p}_{2}}}{{\left({p}_{1}x+{p}_{2}\right)}^{{p}_{1}+{p}_{2}}}\right)}^{\frac{1}{2}}}{xB\left({p}_{1}2,{p}_{2}2\right)}$ $F\left(x\right)=\frac{\underset{0}{\overset{\frac{{p}_{1}x}{{p}_{1}x\phantom{\rule{0.3em}{0ex}}+\phantom{\rule{0.3em}{0ex}}{p}_{2}}}{\int }}{t}^{\frac{{p}_{1}}{2}-1}{\left(1\phantom{\rule{0.3em}{0ex}}-\phantom{\rule{0.3em}{0ex}}t\right)}^{\frac{{p}_{2}}{2}-1}\phantom{\rule{0.3em}{0ex}}\mathrm{d}t}{B\left(\frac{{p}_{1}}{2},\frac{{p}_{1}}{2}\right)}$ W is a matrix with dimensions equal to those of X and entries equal to the pdf/cdf of Fisher’s F distribution with numerator degrees of freedom p1 and denominator degrees of freedom p2, evaluated at each entry of X. The function works element-wise. X must be a matrix or dataset with non-negative entries If X contains negative entries an error is produced p1 must be a positive number p2 must be a positive number W = gampdf(X, alpha, beta); W = gamcdf(X, alpha, beta); $f\left(x\right)=\frac{{\beta }^{\alpha }\cdot {x}^{\alpha -1}\cdot {e}^{-\beta x}}{\Gamma \left(\alpha \right)}$ $F\left(x\right)=\frac{{\beta }^{\alpha }\underset{0}{\overset{x}{\int }}{t}^{\alpha -1}\cdot {e}^{-\beta t}\phantom{\rule{0.3em}{0ex}}\mathrm{d}t}{\Gamma \left(\alpha \right)}$ W is a matrix with dimensions equal to those of X and entries equal to the pdf/cdf of the gamma distribution with shape parameter alpha and rate parameter beta, evaluated at each entry of X. The function works element-wise. X must be a matrix or dataset with non-negative entries If X contains negative entries an error is produced alpha must be a positive number beta must be a positive number W = logisticpdf(X, mu, s); W = logisticcdf(X, mu, s); $f\left(x\right)=\frac{{e}^{-\frac{x-\mu }{s}}}{s\cdot {\left(1+{e}^{-\frac{x-\mu }{s}}\right)}^{2}}$ $F\left(x\right)=\frac{1}{1+{e}^{-\frac{x-\mu }{s}}}$ W is a matrix with dimensions equal to those of X and entries equal to the pdf/cdf of the logistic distribution with mean mu and scale parameter s (variance equal to $\frac{{\mathtt{s}}^{2}{\pi }^{2}}{3}$), evaluated at each entry of X. The function works element-wise. X must be a matrix or dataset mu must be a number s must be a positive number W = logitnpdf(X, mu, sigma); W = logitncdf(X, mu, sigma); $f\left(x\right)=\frac{exp\left\{-\frac{{\left(log\left(\frac{x}{1-x}\right)-\mu \right)}^{2}}{2{\sigma }^{2}}\right\}}{x\left(1-x\right)\sqrt{2\pi {\sigma }^{2}}}$ $F\left(x\right)=\underset{0}{\overset{x}{\int }}\frac{exp\left\{-\frac{{\left(log\left(\frac{t}{1-t}\right)-\mu \right)}^{2}}{2{\sigma }^{2}}\right\}}{t\left(1-t\right)\sqrt{2\pi {\sigma }^{2}}}\phantom{\rule{0.3em}{0ex}}\mathrm{d}t$ W is a matrix with dimensions equal to those of X and entries equal to the pdf/cdf of logit-Normal distribution with location parameter mu and scale parameter sigma, evaluated at each entry of X. The function works element-wise. X must be a matrix or dataset with entries between zero and one If X contains negative entries or entries greater than one an error is produced mu must be a number sigma must be a positive number W = lognpdf(X, mu, sigma); W = logncdf(X, mu, sigma); $f\left(x\right)=\frac{exp\left\{-\frac{{\left(log\left(x\right)-\mu \right)}^{2}}{2{\sigma }^{2}}\right\}}{x\sqrt{2\pi {\sigma }^{2}}}$ $F\left(x\right)=\underset{0}{\overset{x}{\int }}\frac{exp\left\{-\frac{{\left(log\left(t\right)-\mu \right)}^{2}}{2{\sigma }^{2}}\right\}}{t\sqrt{2\pi {\sigma }^{2}}}\phantom{\rule{0.3em}{0ex}}\mathrm{d}t$ W is a matrix with dimensions equal to those of X and entries equal to the pdf/cdf of the log-Normal distribution with location parameter mu and scale parameter sigma, evaluated at each entry of X. The function works element-wise. X must be a matrix or dataset with non-negative entries If X contains negative entries an error is produced mu must be a positive number sigma must be a positive number W = normpdf(X, mu, sigma); W = normcdf(X, mu, sigma); $f\left(x\right)=\frac{exp\left\{-\frac{{\left(x-\mu \right)}^{2}}{{\sigma }^{2}}\right\}}{\sqrt{2\pi {\sigma }^{2}}}$ $F\left(x\right)=\underset{-\infty }{\overset{x}{\int }}\frac{exp\left\{-\frac{{\left(t-\mu \right)}^{2}}{{\sigma }^{2}}\right\}}{\sqrt{2\pi {\sigma }^{2}}}\phantom{\rule{0.3em}{0ex}}\mathrm{d}t$ W is a matrix with dimensions equal to those of X and entries equal to the pdf/cdf of the normal distribution with mean parameter mu and standard deviation sigma, evaluated at each entry of X. The function works element-wise. X must be a matrix or dataset mu must be number sigma must be a positive number W = tpdf(X, p); W = tcdf(X, p); $f\left(x\right)=\frac{\Gamma \left(\frac{p+1}{2}\right)}{\sqrt{p\pi }\Gamma \left(p2\right)}{\left(1+\frac{{x}^{2}}{p}\right)}^{-\frac{p+1}{2}}$ $F\left(x\right)=\underset{-\infty }{\overset{x}{\int }}\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}\frac{\Gamma \left(\frac{p+1}{2}\right)}{\sqrt{p\pi }\Gamma \left(p2\right)}{\left(1\phantom{\rule{0.3em}{0ex}}+\phantom{\rule{0.3em}{0ex}}\frac{{t}^{2}}{p}\right)}^{-\frac{p+1}{2}}\mathrm{d}t$ W is a matrix with dimensions equal to those of X and entries equal to the pdf/cdf of the t distribution with p degrees of freedom, evaluated at each entry of X. The function works element-wise. X must be a matrix or dataset p must be a positive number W = truncnpdf(X, mu, sigma); W = truncncdf(X, mu, sigma); $f\left(x\right)=\frac{\frac{1}{\sigma }\varphi \left(-\frac{\mu }{\sigma }\right)}{1-\Phi \left(-\mu \sigma \right)}$ $F\left(x\right)=\frac{\Phi \left(\frac{x-\mu }{\sigma }\right)-\Phi \left(-\frac{\mu }{\sigma }\right)}{1-\Phi \left(-\mu \sigma \right)}$ where: $\varphi \left(\right)$ is the standard normal pdf$\Phi \left(\right)$ is the standard normal cdf W is a matrix with dimensions equal to those of X and entries equal to the pdf/cdf of a Normal distribution with location parameter mu and scale parameter sigma, truncated from below at zero and evaluated at each entry of X. The function works element-wise. X must be a matrix or dataset with non-negative entries mu must be a number sigma must be a positive number W = wblpdf(X, alpha, beta); W = wblcdf(X, alpha, beta); $f\left(x\right)=\frac{\alpha }{\beta }{\left(\frac{x}{\beta }\right)}^{\alpha -1}{e}^{-{\left(\frac{x}{\beta }\right)}^{\alpha }}$ $F\left(x\right)=1-{e}^{-{\left(\frac{x}{\beta }\right)}^{\alpha }}$ W is a matrix with dimensions equal to those of X and entries equal to the pdf/cdf of the Weibull distribution with shape parameter alpha and scale parameter beta, evaluated at each entry of X. The function works element-wise. X must be a matrix or dataset with non-negative entries If X contains negative entries an error is produced alpha must be a positive number beta must be a positive number
 Syntax Mathematical expression Arguments and return values W = binompdf(X, n, p); W = binomcdf(X, n, p); $f\left(x\right)=\frac{n!}{x!\left(n-x\right)!}{p}^{x}{\left(1-p\right)}^{n-x}$ $F\left(x\right)={\sum }_{k=0}^{x}\frac{n!}{k!\left(n-k\right)!}{p}^{k}{\left(1-p\right)}^{n-k}$ W is a matrix with dimensions equal to those of X and entries equal to the pdf/cdf of the binomial distribution with n of trials and probability of success in each trial p, evaluated at each entry of X. The function works element-wise. X must be a matrix or dataset with integer entries between zero and n If X contains negative entries or entries above n an error is produced n must be a non-negative number p must be a number between zero and one Note that the function allows for non-integer values of n by replacing the factorials in the expression by the Gamma function. W = nbinompdf(X, n, p); W = nbinomcdf(X, n, p); $f\left(x\right)=\frac{\left(x\phantom{\rule{0.3em}{0ex}}+\phantom{\rule{0.3em}{0ex}}n\phantom{\rule{0.3em}{0ex}}-\phantom{\rule{0.3em}{0ex}}1\right)!}{x!\left(n\phantom{\rule{0.3em}{0ex}}-\phantom{\rule{0.3em}{0ex}}1\right)!}{p}^{x}{\left(1-p\right)}^{n}$ $F\left(x\right)={\sum }_{k=0}^{x}\frac{\left(x\phantom{\rule{0.3em}{0ex}}+\phantom{\rule{0.3em}{0ex}}n\phantom{\rule{0.3em}{0ex}}-\phantom{\rule{0.3em}{0ex}}1\right)!}{x!\left(n\phantom{\rule{0.3em}{0ex}}-\phantom{\rule{0.3em}{0ex}}1\right)!}{p}^{x}{\left(1-p\right)}^{n}$ W is a matrix with dimensions equal to those of X and entries equal to the pdf/cdf of the negative-binomial distribution with n failures until stopping and probability of success in each trial p, evaluated at each entry of X. The function works element-wise. X must be a matrix or dataset with non-negative integer entries If X contains negative entries an error is produced n must be a positive number p must be a number between zero and one Note that the function allows for non-integer values of n by replacing the factorials in the expression by the Gamma function. W = poissonpdf(X, lambda); W = poissoncdf(X, lambda); $f\left(x\right)=\frac{{\lambda }^{x}{e}^{-\lambda }}{x!}$ $F\left(x\right)=\frac{{\lambda }^{k}{e}^{-\lambda }}{k!}$ W is a matrix with dimensions equal to those of X and entries equal to the pdf/cdf of the Poisson distribution with rate parameter lambda, evaluated at each entry of X. The function works element-wise. X must be a matrix or dataset with non-negative integer entries If X contains negative entries an error is produced lambda must be a positive number