probability functions

Function:

FACT

Function Name:

Factorial (n!)

Syntax:

FACT(n)

Description:

Returns n!, the factorial of n. n! is equivalent to the multiplicative series

n * (n – 1) * … * 2 * 1

Factorials are commonly used in calculating probabilities and permutations.

Example Usage:

FACT(5)

Return Value:

120



Function:

CHOOSE

Function Name:

Choose

Syntax:

CHOOSE(n, r)

Description:

Returns the result of performing the stochastic operation n choose r. n choose r is the number of ways that r objects can be selected from n unique objects, where the order of selection of the r objects is not relevant. n choose r is equivalent to

n! _

r!(n-r)!

Both arguments to CHOOSE must be positive integer values.

Example Usage:

CHOOSE(9, 4)

Return Value:

126





Function:

PERMUTAT

Function Name:

Permutate

Syntax:

PERMUTAT(n,r)

Description:

Returns the result of performing the stochastic operation n permutate r. n permutate r is the number of ways that r objects can be selected from n unique objects, where the order of selection of the r objects is considered relevant. n permutate r is equivalent to

n! _

(n-r)!

Both arguments to PERMUTAT must be positive integer values.

Example Usage:

PERMUTAT(5, 3)

Return Value:

60




Function:

RANDOM

Function Name:

Random number generator

Syntax:

RANDOM(0)

Description:

Returns a pseudo-random number in the range 0 < n < 1.

No seeding is necessary for the CobolScript random number generator because the generator is internally seeded with each call to the RANDOM function; however, because of this, it is not possible with CobolScript Standard Edition to repeat a random number series with consecutive runs of the same CobolScript program.

Also, because the auto-seeding process is dependent on the processor clock, and seeding is done with the first call to the RANDOM function within any one program, closely timed, periodic runs of a program that makes one call to the random number generator will not necessarily generate a good random profile, or a non-correlative scattering of the plotted random numbers. To achieve good non-correlative scattering, the RANDOM function must either be called multiple times within the same program, or the times at which the program is called must itself be somewhat random, such as with a CGI or other on-demand type of application.

An argument of 0 (zero) should always be specified for RANDOM.

Example Usage:

RANDOM(0)

Return Value:

Trial 1: 0.3203833125

Trial 2: 0.0529190954

Trial 3: 0.6378368480

Trial 4: 0.4803613392