For the latest version of JMP Help, visit JMP.com/help.


Publication date: 06/21/2023

Random Functions

Col Shuffle(<By var,...>)

Description

Creates a random ordering of the row numbers of the current data table when used in a column formula.

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

Returns

A random integer between 1 and the number of rows in the current data table.

Argument

By var

(Optional) A By variable enables you to randomly order the rows within the groups of the By variable values.

Example

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "Shuffle", Numeric, Continuous, Set Formula( Col Shuffle() ) );

This example creates a column formula that shuffles the order of the row numbers (1 to 40) each time the formula is evaluated. Each number appears only once.

Make Validation Formula(rates, <<Stratification Columns(cols), <<Grouped Columns(cols), <<Cutpoint Column(col))

Description

Generates a validation column. This function is primarily used by the Make Validation Column utility.

Arguments

rates

Vector of three rates that specify the training, validation, and test rates, respectively.

<<Stratification Columns

Assigns one or more stratification columns.

<<Grouped Columns

Assigns one or more grouping columns.

<<Cutpoint Column

Assigns a numeric cutpoint column.

See Also

Make Validation Column in Predictive and Specialized Modeling

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 one of the specified result expressions at random, chosen from 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.

Arguments

probA

Numeric value between 0 and 1 that represents the probability of the corresponding result expression being returned.

resultA

Expression that corresponds to probA.

resultElse

Expression that is returned if no previous result expression has been 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 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(n)

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 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(n, p)

Description

Returns a random number from a negative binomial distribution for n 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. To ensure reproducible results, specify a positive integer less than or equal to 4,294,967,295 for the random seed.

Notes

You can use the Random Reset function to set a random seed that enables you to reproduce a set of random numbers. The random number algorithms in JMP are sometimes refined, and therefore the results might not be consistent across different versions of JMP.

Random Seed State(<seed state>)

Description

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

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 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(shape, <scale=1>)

Description

Returns a random number from a Weibull distribution with parameters shape and optional scale.

Arguments

shape

Shape parameter β, which must be greater than 0.

scale

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.

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;

Notes

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 the same expected value); however, the values vary somewhat due to random selection at the rates corresponding to the old frequency column.

Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).