Publication date: 07/30/2020

# Random Functions

You can create formulas that generate random numbers by effectively “rolling the dice” within the constraints of the specified distribution. Each time you click Apply in the Formula Editor window, these functions produce a new set of random numbers.

Note: Random numbers are generated using the Mersenne-Twister technique. This technique has a period length of 219937-1. For more information about the generators, see Matsumoto and Nishimura (1998). The new generators are verified to pass all the DIEHARD tests as documented in Marshalled (1996).

See Random Functions in the JSL Syntax Reference for more information about distribution parameterizations and function arguments.

#### Random ChiSquare

Generates a column of random numbers from a Chi-Square distribution with the specified df (degrees of freedom). The optional noncentrality parameter must be greater than or equal to zero. The noncentrality parameter is zero by default.

#### Random F

Generates a column of random numbers from an F distribution with the specified dfn (numerator degrees of freedom) and dfd (denominator degrees of freedom). The optional noncentrality parameter must be greater than or equal to zero. The noncentrality parameter is zero by default.

#### Random Index

Returns a k by 1 matrix of random integers between 1 and n with no duplicates.

#### Random Uniform

Generates a column of random numbers from a uniform distribution. If no arguments are specified, the minimum of the uniform distribution is 0 and the maximum is 1. This means that any number between 0 and 1 is as likely to be generated as any other. The result is an approximately even distribution. You can use the optional arguments to specify different values for the minimum and maximum numbers of the uniform distribution.

#### Random Normal

Generates a column of random numbers from a normal distribution. If no arguments are specified, the normal distribution has a mean of 0 and standard deviation of 1. You can use the optional arguments to specify different values for the mean and standard deviation.

#### Random Normal Mixture

Returns a random number from a normal mixture distribution with the specified arguments.

#### Random Exp

Generates a single parameter exponential distribution for the distribution parameter lambda=1. You can scale the exponential function to use a different lambda. For example, Random Exp()*.1 generates an exponential distribution for lambda=0.1. The exponential distribution is often used to model simple failure time data, where lambda is the failure rate.

#### Random Gamma

Gives a gamma distribution for the parameter, alpha, you enter as the function argument. The gamma distribution describes the time until the kth occurrence of an event. The gamma distribution can also have a scale parameter, beta. A gamma variate with shape parameter alpha and scale beta can be generated with the formula beta*Random Gamma(alpha). If 2*alpha is an integer, a Chi-squared variate with 2*alpha degrees of freedom is generated with the formula 2*Random Gamma(alpha).

#### Random GenGamma

Returns a random number from an extended generalized gamma distribution with parameters mu, sigma, and lambda.

#### Random LogGenGamma

Returns a random number from an extended generalized gamma distribution with parameters mu, sigma, and lambda.

#### Random Beta

Generates a pseudo-random number distributed Beta(alpha, beta).

#### Random Cauchy

Generates a Cauchy distribution with location parameter 0 and scale parameter 1. The Cauchy distribution is bell shaped and symmetric but has heavier tails than the normal distribution. A Cauchy variate with location parameter alpha and scale parameter beta can be generated with the formula alpha+beta*Random Cauchy().

#### Random Category

Generates a random category given an alternation of probability and result expressions (for example, Random Category(.2, "A", .3, "B", .4, "C", "D");).

#### Random Johnson Su

Returns a random number from the Johnson Su distribution.

#### Random Johnson Sb

Returns a random number from the Johnson Sb distribution.

#### Random Johnson Sl

Returns a random number from the Johnson Sl distribution.

#### Random Seed State

Retrieves or restores the random seed state to or from a BLOB object.

#### Random Triangular

Generates a triangular distribution of numbers between 0 and 1, with the midpoint that you enter as the function argument. You can add a constant to the function to shift the distribution and multiply to change its span.

#### Random Integer

Generates a uniform distribution of integers between 1 and the argument that you enter as n1, if nothing is entered for n2. If you enter both n1 and n2 (n1<n2), Random Integer generates a uniform distribution of the integers between and including n1 and n2.

#### Random Binomial

Generates random numbers from a binomial distribution with parameters that you enter as function arguments. The first argument is n, the number of trials in a binomial experiment. The second argument is p, the probability that the event of interest occurs. When n is 1, the binomial function generates a distribution of Bernoulli trials. For example, n =1 and p = 0.5, give the distribution of tossing a fair coin. The mean of the binomial distribution is np, and variance is np(1 – p).

#### Random Negative Binomial

Generates a negative binomial distribution for the parameters that you enter as function arguments. The first parameter is the number of successes of interest (r) and the second argument is the probability of success (p). The random variable of interest is the number of failures that precede the rth success. In contrast to the binomial variate, where the number of trials is fixed and the number of successes is variable, the negative binomial variate is for a fixed number of successes and a random number of trials. The mean of the negative binomial distribution is (r(1 – p))/p and the variance is (r(1 – p))/p2.

#### Random Beta Binomial

Returns random numbers from the beta binomial distribution for n trials with probability p and correlation or overdispersion delta.

#### Random Frechet

Returns a random number from a Fréchet distribution with the location mu and scale sigma.

#### Random Geometric

Returns random numbers from the geometric distribution with the parameter that you enter as the function argument. The parameter, p, is the probability that a specific event occurs at any one trial. The number of trials until a specific event occurs for the first time is described by the geometric distribution. The mean of the geometric distribution is (1-p)/p, and the variance is (1 – p)/p2.

#### Random Poisson

Generates a Poisson variate based on the value of the parameter, lambda, you enter as the function argument. Lambda is often the expected number of events occurring per unit time or unit of area. Lambda is both the mean and the variance of the Poisson distribution.

#### Random Gamma Poisson

Returns random numbers from the gamma Poisson distribution with parameters lambda and sigma.

#### Random Weibull

Returns a random number from a Weibull distribution.

#### Random Logistic

Returns a random number from a logistic distribution with the location mu and scale sigma.

#### Random Loglogistic

Returns a random number from a loglogistic distribution with the location mu and scale sigma.

#### Random Lognormal

Returns a Lognormal-distributed random number with location parameter mu and scale sigma.

#### Random GLog

Returns random numbers from the generalized logarithm distribution with parameters mu, sigma, and lambda. When lambda is equal to zero, the function returns a lognormal(mu, sigma).

#### Random Reset

Restarts the random number sequences with a seed that you specify.

#### Random LEV

Returns a random number from an LEV distribution with the specified location mu and scale sigma.

#### Random SEV

Returns a random number from the smallest extreme distribution with the specified location mu and scale sigma.

#### Random SHASH

Returns a random number from the sinh-arcsinh (SHASH) distribution.

#### Random Shuffle

Returns the matrix with the elements shuffled into a random order.

#### Random t

Returns a random number from a t distribution with the specified df (degrees of freedom). The optional noncentrality argument may be negative or positive. The default value of noncentral is 0.

#### Col Shuffle

Selects a row number at random from the current data table. Each row number is selected only once. When Col Shuffle is used as a subscript, it returns a value selected at random from the column that serves as its argument. Each value from the original column is assigned only once as Col Shuffle’s result.

For example, to identify a 50% random sample without replacement, use the formula in Figure A.16.

Figure A.16 Formula Identifying 50% Random Sample The formula in Figure A.16 selects half the values (n/2) from the column x and assigns them to the first half of the rows in the computed column. The remaining rows of the computed column fill with missing values.

#### Resample Freq

Generates a random selection with replacement frequency counts, suitable for use in bootstrapping. For example, it supports a second Freq Column argument, enabling it to do bootstrap samples relating to a pre-existing frequency column specified in the second argument. Resample Freq() generates a 100% resample. ResampleFreq(rate) generates a rate frequency sample. Resample(rate, column) generates a sample that is calculated by the rate multiplied by the sum of the specified column.