prob


prob, a FORTRAN77 code which handles various discrete and continuous probability density functions ("PDF's").

For a discrete variable X, PDF(X) is the probability that the value X will occur; for a continuous variable, PDF(X) is the probability density of X, that is, the probability of a value between X and X+dX is PDF(X) * dX.

The corresponding cumulative density functions or "CDF"'s are also handled. For a discrete or continuous variable, CDF(X) is the probability that the variable takes on a value less than or equal to X.

In some cases, the inverse of the CDF can easily be computed. If


        X = CDF_INV ( P )
      
then we are asserting that the value X has a cumulative probability density function of P, in other words, the probability that the variable is less than or equal to X is P. If the CDF cannot be analytically inverted, there are simple ways to try to estimate the inverse. Depending on the PDF, these methods may be rapid and accurate, or not.

For most distributions, the mean or "average value" or "expected value" is also available. For a discrete variable, MEAN is simply the sum of the products X * PDF(X); for a continuous variable, MEAN is the integral of X * PDF(X) over the range. For the distributions covered here, the means are known beforehand, and no summation or integration is required.

For most distributions, the variance is available. For a discrete variable, the variance is the sum of the products ( X - MEAN )^2 * PDF(X); for a continuous variable, the variance is the integral of ( X - MEAN )^2 * PDF(X) over the range. The square root of the variance is known as the standard deviation. For the distributions covered here, the variances are often known beforehand, and no summation or integration is required.

For many of the distributions, it is possible to repeatedly request "samples", that is, a pseudorandom sequence of realizations of the PDF. These samples are always associated with an integer seed, which controls the calculation. Using the same seed as input will guarantee the same sample value on output. Ultimately, a random number generator must be invoked internally. In most cases, the current code will call a routine called R8_UNIFORM_01, which uses a very basic, and old, random number generator. You may prefer a different random number generator for this purpose.

Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Languages:

prob is available in a C version and a C++ version and a FORTRAN77 version and a FORTRAN90 version and a MATLAB version and a Python version.

Related Data and Programs:

ASA005, a FORTRAN77library which evaluates the CDF of the noncentral T distribution.

ASA066, a FORTRAN77 library which evaluates the CDF of the normal distribution.

ASA076, a FORTRAN77 library which evaluates the Owen's T function, needed to compute the CDF of the noncentral T distribution.

ASA091, a FORTRAN77 library which evaluates the percentage points of the Chi-Squared distribution.

ASA111, a FORTRAN77 library which evaluates the percentage points of the normal distribution.

ASA152, a FORTRAN77 library which evaluates point and cumulative probabilities associated with the hypergeometric distribution; this is Applied Statistics Algorithm 152;

ASA226, a FORTRAN77 library which evaluates the CDF of the noncentral Beta distribution.

ASA241, a FORTRAN77 library which evaluates the percentage points of the normal distribution.

ASA243, a FORTRAN77 library which evaluates the CDF of the noncentral T distribution.

ASA266, a FORTRAN77 library which evaluates various properties of the Dirichlet probability density function; this is Applied Statistics Algorithm 266;

ASA310, a FORTRAN77 library which computes the CDF of the noncentral Beta distribution.

BETA_NC, a FORTRAN77 library which evaluates the CDF of the noncentral Beta distribution.

CDFLIB, a FORTRAN90 library which evaluates the cumulative density function (CDF), inverse CDF, and certain other inverse functions, for distributions including beta, binomial, chi-square, noncentral chi-square, F, noncentral F, gamma, negative binomial, normal, Poisson, and students T, by Barry Brown, James Lovato, Kathy Russell.

DISCRETE_PDF_SAMPLE_2D, a FORTRAN77 program which demonstrates how to construct a Probability Density Function (PDF) from a table of sample data, and then to use that PDF to create new samples.

NORMAL, a FORTRAN77 library which samples the normal distribution.

RANLIB, a FORTRAN77 library which produces random samples from Probability Density Functions (PDF's), including Beta, Chi-square Exponential, F, Gamma, Multivariate normal, Noncentral chi-square, Noncentral F, Univariate normal, random permutations, Real uniform, Binomial, Negative Binomial, Multinomial, Poisson and Integer uniform, by Barry Brown and James Lovato.

TEST_VALUES, a FORTRAN77 library which contains sample values for a number of distributions.

TOMS441, a FORTRAN77 library which samples the dipole distribution;
this is ACM TOMS algorithm 441.

TOMS725, a FORTRAN77 library which evaluates multivariate normal integrals associated with the computation of cumulative probabilities associated with a multidimensional variable governed by a normal probability density function with a known correlation matrix, by Zvi Drezner. This is a version of ACM TOMS algorithm 725.

TRUNCATED_NORMAL, a FORTRAN77 library which works with the truncated normal distribution over [A,B], or [A,+oo) or (-oo,B], returning the probability density function (PDF), the cumulative density function (CDF), the inverse CDF, the mean, the variance, and sample values.

UNIFORM, a FORTRAN77 library which samples the uniform distribution.

ZIGGURAT, a FORTRAN77 program which generates points from a uniform, normal or exponential distribution, using the ziggurat method.

Source Code:


Last revised on 15 July 2022.