Probability Functions

LINGO has a number of probability related functions. There are examples that make use of most of these functions in Developing More Advanced Models and in Additional Examples of LINGO Modeling.

@NORMINV( P, MU, SIGMA)

The inverse of the normal cumulative distribution.  Given a probability, P,  the mean of the of the normal distribution, MU, and its standard deviation, SIGMA, this function returns the value Z such that the probability of a normally distributed random variable being less-than-or-equal to Z is P.  This function is being replaced by the @PNORMINV function, documented below in the Distributions section.

@NORMSINV( P)

The inverse of the standard normal cumulative distribution.  Given a probability, P, this function returns the value Z such that the probability of a normally distributed random variable with a mean of 0 and a standard deviation of 1 being less-than-or-equal to Z is P.

@PBN( P, N, X)

The cumulative binomial probability. It returns the probability that a sample of N items, from a universe with a fraction of P of those items defective, has X or less defective items. It is extended to non-integer values of X and N by linear interpolation.  This function is being replaced by the @PBINOCDF function, documented below in the Distributions section.

@PCX( N, X)

The cumulative distribution function for the Chi-squared distribution with N degrees of freedom. It returns the probability that an observation from this distribution is less-than-or-equal-to X.  This function is being replaced by the @PCHISCDF function, documented below in the Distributions section.

@PEB( A, X)

Erlang’s busy probability for a service system with X servers and an arriving load of A, with infinite queue allowed. The result of @PEB can be interpreted as either the fraction of time all servers are busy or the fraction of customers that must wait in the queue. It is extended to noninteger values of X by linear interpolation. The arriving load, A, is the expected number of customers arriving per unit of time multiplied by the expected time to process one customer.

@PEL( A, X)

Erlang’s loss probability for a service system with X servers and an arriving load of A, no queue allowed. The result of @PEL can be interpreted as either the fraction of time all servers are busy or the fraction of customers lost due to all servers being busy when they arrive. It is extended to noninteger values of X by linear interpolation. The arriving load, A, is the expected number of customers arriving per unit of time multiplied by the expected time to process one customer.

@PFD( N, D, X)

Cumulative distribution function for the F distribution with N degrees of freedom in the numerator and D degrees of freedom in the denominator. It returns the probability that an observation from this distribution is less-than-or-equal-to X.  This function is being replaced by the @PFDSTCDF function, documented below in the Distributions section.

@PFS( A, X, C)

Returns the expected number of customers waiting for or under repair in a finite source Poisson service system with X servers in parallel, C customers, and a limiting load A. It is extended to noninteger values of X and C by linear interpolation. A, the limiting load, is the number of customers multiplied by the mean service time divided by the mean repair time.

@PHG( POP, G, N, X)        

The cumulative hypergeometric probability. It returns the probability that X or fewer items in the sample are good, given a sample without replacement of N items from a population of size POP where G items in the population are good. It is extended to noninteger values of POP, G, N, and X by linear interpolation.  This function is being replaced by the @PHYPGCDF function, documented below in the Distributions section.

@PPL( A, X)

The linear loss function for the Poisson distribution. It returns the expected value of MAX( 0, Z-X), where Z is a Poisson random variable with mean value A.

@PPS( A, X)

The cumulative Poisson probability distribution. It returns the probability that a Poisson random variable, with mean value A, is less-than-or-equal-to X. It is extended to noninteger values of X by linear interpolation.  This function is being replaced by the @PPOISCDF function, documented below in the Distributions section.

@PSL( X)

The unit normal linear loss function. It returns the expected value of MAX( 0, Z-X), where Z is a standard normal random variable. In inventory modeling, @PSL( X) is the expected amount that demand exceeds a level X, if demand has a standard normal distribution.

@PSN( X)

The cumulative standard normal probability distribution. A standard normal random variable has mean 0.0 and standard deviation 1.0 (the bell curve, centered on the origin). The value returned by @PSN is the area under the curve to the left of the point on the ordinate indicated by X.  This function is being replaced by @PNORMCDF function documented below in the Distributions section.

@PTD( N, X)

The cumulative distribution function for the t distribution with N degrees of freedom. It returns the probability that an observation from this distribution is less-than-or-equal-to X.  This function is being replaced by the @PSTUTCDF function, documented below in the Distributions section.

@QRAND( SEED)

@QRAND produces a sequence of "quasi-random" uniform numbers in the n-cube (0,1)^n. @QRAND is only permitted in a data and calc sections. It will fill an entire attribute with quasi-random numbers. Generally, you will be filling two-dimensional tables with, say, m rows and n variables. m represents the number of scenarios, or experiments, you want to run. n represents the number of random variables you need for each scenario or experiment. Within a row, the numbers are independently distributed. Among rows, the numbers are "super uniformly" distributed. That is, the numbers are more uniformly distributed than you would expect by chance. These numbers are generated by a form of "stratified sampling".

For example, suppose m = 10 and n = 2. Even though the numbers are random, you will find that there will be exactly one row in which both numbers are in the interval (0, .5), exactly one row in which both numbers are in (.5, 1), and two rows in which one number is less than .5 and the other is greater than .5. Using @QRAND allows you to get much more accurate results for a given number of random numbers in a Monte Carlo model. If you want 8 ordinary random numbers, then use @QRAND(1,8) rather than @QRAND(4,2). An example of @QRAND follows:

MODEL:

  DATA:

     M = 4;

     N = 2;

     SEED = 1234567;

  ENDDATA

  SETS:

     ROWS /1..M/;

     COLS /1..N/;

     TABLE( ROWS, COLS): X;

  ENDSETS

  DATA:

     X = @QRAND( SEED);

     @TEXT() = @TABLE( X);

  ENDDATA

END

Example of @QRAND function

This example produces the following table of quasi-random numbers:

             1          2

  1  0.2085788  0.1381721

  2  0.6283858  0.2530084

  3  0.3767461  0.7546936

  4  0.9335576  0.5737700

 

If you don’t specify a seed value for @QRAND, then LINGO will use the system clock to construct a seed value.

@RAND( SEED)

Returns a pseudo-random number between 0 and 1, depending deterministically on SEED.