This version of the Help is no longer updated. See JMP.com/help for the latest version.

.
JSL Syntax Reference > JSL Functions > Random Functions
Publication date: 07/30/2020

Random Functions

Col Shuffle()

Description

Shuffles the values randomly each time it’s evaluated.

Returns

The last value placed into the last row.

Argument

none

Example

For Each Row(x=:shuffle = colshuffle());
show(x)

x = 6

In a table with 40 rows, the above script places the values 1-40 randomly into each row of the column named shuffle. All numbers appear only once. Each time the script is run, the numbers are placed in a different random order. If the value placed into the row 40 of column shuffle is 6, that number is assigned to x, as in the above example.

Random Beta(alpha, beta, <theta=0>, <sigma=1>)

Description

Returns a random number from a beta distribution with two shape parameters, alpha and beta, and optional parameters theta and sigma.

Arguments

alpha, beta

Shape parameters α and β, which must both be greater than 0.

theta

Optional threshold parameter θ. The default is 0.

sigma

Optional scale parameter σ, which must be greater than 0. The default is 1.

Random Beta Binomial(n, p, <delta=0>)

Description

Returns a random number from a beta binomial distribution for n trials with probability p and overdispersion parameter delta.

Arguments

n

The number of trials, which must be greater than or equal to 2. If the specified n is not an integer, the non-integer part is truncated.

p

The probability of success for each trial, which must be between 0 and 1.

delta

The overdispersion parameter δ, which must be between Maximum[-p/(n-p-1), -(1-p)/(n-2+p)] and 1. The default is 0.

Random Binomial(n, p)

Description

Returns a random number from a binomial distribution with n trials and probability p of the event of interest occurring.

Arguments

p

The probability of success for each trial, which must be between 0 and 1.

n

The number of trials.

Random Category(probA, resultA, ProbB, resultB, resultElse)

Description

Returns a random category given pairs of probability and result expressions. A random uniform number is generated and compared to the prob arguments to determine which result argument is returned.

Random Cauchy()

Description

Returns a random number from a Cauchy distribution with a median of zero.

Random ChiSquare(df, <nc=0>)

Description

Returns a random number from a chi-square distribution with given df (degrees of freedom) and optional noncentrality parameter.

Arguments

df

The degrees of freedom n, which must be greater than 0.

nc

Optional noncentrality parameter λ, which must be nonnegative. The default is 0.

Random Exp()

Description

Returns a random number from an exponential distribution with scale parameter equal to 1. Equivalent to the negative log of Random Uniform.

Random F(dfnum, dfden, <noncentral=0>)

Description

Returns a random number from an F distribution with a given dfnum, dfden, and optional noncentrality parameter.

Arguments

dfnum

The degrees of freedom, v1, of the chi-square distribution in the numerator of the F-distribution. dfnum must be greater than 0.

dfden

The degrees of freedom, v2, of the chi-square distribution in the denominator of the F-distribution. dfden must be greater than 0.

noncentral

Optional noncentrality parameter λ, which must be nonnegative. The default is 0.

Random Frechet(<mu=0>, <sigma=1>)

Description

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

Arguments

mu

Optional location parameter μ. The default is 0.

sigma

Optional scale parameter σ, which must be greater than 0. The default is 1.

Random Gamma(alpha, <scale=1>)

Description

Returns a random numbers from a gamma distribution for given alpha and optional scale.

Arguments

alpha

The shape parameter α, which must be greater than 0.

scale

Optional scale parameter β, which must be greater than 0. The default is 1.

Random Gamma Poisson(lambda, <sigma=1>)

Description

Returns a random number from a gamma Poisson distribution with parameters lambda and sigma.

Arguments

lambda

The shape parameter λ, which much be greater than 0.

sigma

Optional overdispersion parameter σ, which must be greater than or equal to 1. The default is 1. When the overdispersion parameter is 1, the distribution reduces to a Poisson(λ) distribution.

Random GenGamma(<mu=0>, <sigma=1>, <lambda=0>)

Description

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

Arguments

mu

Optional location parameter μ. The default is 0.

sigma

Optional scale parameter σ, which must be greater than 0. The default is 1.

lambda

Optional shape parameter λ. The allowable range is -12 < λ < 12. The default is 0.

Random Geometric(p)

Description

Returns a random number from the geometric distribution with probability p that a specific event occurs at any one trial.

Random GLog(mu, sigma, lambda)

Description

Returns a random number from a generalized logarithmic distribution with parameters mu, sigma, and lambda.

Arguments

mu

The location parameter μ.

sigma

The scale parameter σ, which must be greater than 0.

lambda

A shape parameter λ, which must be greater than 0.

Random Index(n, k)

Description

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

Random Integer(k, n)

Description

Returns a random integer from 1 to n or from k to n.

Random Johnson Sb(gamma, delta, theta, sigma)

Description

Returns a random number from a Johnson Sb distribution with parameters gamma, delta, theta, and sigma.

Arguments

gamma

Shape parameter γ.

delta

Shape parameter δ, which must be greater than 0.

theta

Location parameter θ.

sigma

Scale parameter σ, which must be greater than 0.

Random Johnson Sl(gamma, delta, theta, <sigma=1>)

Description

Returns a random number from a Johnson Sl distribution with parameters gamma, delta, theta, and optional sigma.

Arguments

gamma

Shape parameter γ.

delta

Shape parameter δ, which must be greater than 0.

theta

Location parameter θ.

sigma

Optional parameter σ that indicates if the distribution is skewed positively or negatively. sigma must be equal to either +1 (skewed positively) or -1 (skewed negatively). The default is 1.

Random Johnson Su(gamma, delta, theta, sigma)

Description

Returns a random number from a Johnson Su distribution with parameters gamma, delta, theta, and sigma.

Arguments

gamma

Shape parameter γ.

delta

Shape parameter δ, which must be greater than 0.

theta

Location parameter θ.

sigma

Scale parameter σ, which must be greater than 0.

Random LEV(<mu=0>, <sigma=1>)

Description

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

Arguments

mu

Optional location parameter μ. The default is 0.

sigma

Optional scale parameter σ, which must be greater than 0. The default is 1.

Random LogGenGamma(<mu=0>, <sigma=1>, <lambda=0>)

Description

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

Arguments

mu

Optional location parameter μ. The default is 0.

sigma

Optional scale parameter σ, which must be greater than 0. The default is 1.

lambda

Optional shape parameter λ. The allowable range is -12 < λ < 12. The default is 0.

Random Logistic(<mu=0>, <sigma=1>)

Description

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

Arguments

mu

Optional location parameter μ. The default is 0.

sigma

Optional scale parameter σ, which must be greater than 0. The default is 1.

Random Loglogistic(<mu=0>, <sigma=1>)

Description

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

Arguments

mu

Optional location parameter μ. The default is 0.

sigma

Optional scale parameter σ, which must be greater than 0. The default is 1.

Random Lognormal(<mu=0>, <sigma=1>)

Description

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

Arguments

mu

Optional location parameter μ. The default is 0.

sigma

Optional scale parameter σ, which must be greater than 0. The default is 1.

Random Multivariate Normal(mean, covar, <nrows=1>)

Description

Returns a random vector from a multivariate normal distribution with mean vector mean and covariance matrix covar. To generate multiple vectors, specify an integer greater than 1 for the nrows argument. When nrows is greater than 1, the return value is a matrix. The number of columns in the random vector or matrix is equal to the number of rows in the covar argument.

Arguments

mean

Mean vector for the multivariate normal distribution.

covar

Covariance matrix for the multivariate normal distribution. This matrix must be a symmetric square matrix that contains the same number of columns as the mean vector.

nrows

Optional argument that specifies the number of random vectors returned. The default number of rows is 1.

Random Negative Binomial(r, p)

Description

Returns a random number from a negative binomial distribution for r successes with probability of success p.

Random Normal(<mu=0>, <sigma=1>)

Description

Returns a random number from a normal distribution with mean mu and standard deviation sigma.

Arguments

mu

Optional location parameter μ. The default is 0.

sigma

Optional scale parameter σ, which must be greater than 0. The default is 1.

Random Normal Mixture(meanvec, sdvec, probabvec)

Description

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

Arguments

meanvec

A vector that contains group means.

sdvec

A vector that contains the group standard deviations.

probvec

A vector that contains the group probabilities.

Random Poisson(lambda)

Description

Returns a random number from a Poisson distribution with shape parameter lambda.

Arguments

lambda

The shape parameter λ, which much be greater than 0.

Random Reset(seed)

Description

Restarts the random number sequences with seed.

Random SEV(<mu=0>, <sigma=1>)

Description

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

Arguments

mu

Optional location parameter μ. The default is 0.

sigma

Optional scale parameter σ, which must be greater than 0. The default is 1.

Random SHASH(gamma, delta, theta, sigma)

Description

Returns a random number from a sinh-arcsinh (SHASH) distribution with parameters gamma, delta, theta, and sigma.

Arguments

gamma

The shape parameter γ.

delta

The shape parameter δ, which must be greater than 0.

theta

The location parameter θ.

sigma

The scale parameter σ, which must be greater than 0.

Random Seed State(<seed state)

Description

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

Random Shuffle(matrix)

Description

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

Random t(df, <noncentral=0>)

Description

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

Random Triangular(min, mode, max)

Random Triangular(mode, max)

Random Triangular(mode)

Description

Generates a random number from a triangular distribution between 0 and 1 with the mode that you specify. The triangular distribution is typically used for populations that have a small number of data.

Arguments

min

Specifies the lower limit of the triangular distribution. The default value is 0.

mode

Specifies the mode of the triangular distribution.

max

Species the upper limit of the triangular distribution. The default value is 1.

Notes

If you specify only the mode, the minimum value is 0, and the maximum value is 1. If you specify the mode and maximum value, the minimum value is 0 by default.

Random Uniform()

Random Uniform(x)

Random Uniform(min, max)

Description

Generates a random number from a uniform distribution between 0 and 1. Random Uniform(x) generates a number between 0 and x. Random Uniform (min, max) generates a number between min and max. The result is an approximately even distribution.

Random Weibull(beta, <alpha=1>)

Description

Returns a random number from a Weibull distribution with parameters beta and optional alpha.

Arguments

beta

Shape parameter β, which must be greater than 0.

alpha

Optional scale parameter α, which must be greater than 0. The default is 1.

Resample Freq(<rate=1, <column>>)

Description

Generates a frequency count for sampling with replacement. If no arguments are specified, the function generates a 100% resample.

Note: This function is generally used in a column formula.

Arguments

rate

(Optional) Specifies the rate of resampling. The default value is 1. A negative value specifies that fractional frequencies are allowed.

column

(Optional) If you specify column, you must also specify rate. The sample size is calculated by the rate multiplied by the sum of the specified column. If rate is negative, then the sample size is the negative of the rate multiplied by the sum of the specified column. If you do not specify a column, the generated frequencies sum to the number of rows.

Note

A typical use of this function generates a column with many 1s, some 0s, some 2s, and so forth, corresponding to which rows were randomly assigned any of n randomly selected rows.

A typical use of this with an existing frequency column produces a new frequency column whose values are similar to the old frequency column (have that expected value); however, the values vary somewhat due to random selection at the rates corresponding to the old frequency column.

Example

To ensure that the numbers in the frequency column match each time you run the script, use As Constant(). As Constant() evaluates an expression to create a constant value that does not change after it has been computed.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dc = dt << New Column( "column",
	Formula(
		As Constant(
			Random Reset( 123 );
			0;
		) + Resample Freq()
	)
);
dc << Eval Formula;
Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).