RAND Function
Generates random numbers from a distribution that you specify.
| Categories: | Random Number |
| CAS |
Syntax
Required Arguments
distribution
is a character constant, variable, or expression that identifies the distribution. Valid distributions are as follows:
|
Distribution
|
Argument
|
|---|---|
| Bernoulli |
BERNOULLI |
| Beta |
BETA |
| Binomial |
BINOMIAL |
| Cauchy |
CAUCHY |
| Chi-Square |
CHISQUARE |
| Erlang |
ERLANG |
| Exponential |
EXPONENTIAL |
| F |
F |
| Gamma |
GAMMA |
| Geometric |
GEOMETRIC |
| Hypergeometric |
HYPERGEOMETRIC |
| Lognormal |
LOGNORMAL |
| Negative Binomial |
NEGBINOMIAL |
| Normal |
NORMAL|GAUSSIAN |
| Poisson |
POISSON |
| T |
T |
| Tabled |
TABLE |
| Triangular |
TRIANGLE |
| Uniform |
UNIFORM |
| Weibull |
WEIBULL |
parameter-1, …, parameter-k
are optional numeric constants, variables, or expressions that specify the values of shape, location, or scale parameters appropriate for the specific distribution.
| See | Details |
Details
Generating Random Numbers
Reproducing a Random Number Stream
Duplicate Values in the Mersenne-Twister RNG Algorithm
Bernoulli Distribution
Beta Distribution
x
a
is a numeric constant, variable, or expression that specifies a shape parameter.
| Range | a > 0 |
b
is a numeric constant, variable, or expression that specifies a shape parameter.
| Range | b > 0 |
Binomial Distribution
x
p
is a numeric constant, variable, or expression that specifies the probability of success.
| Range | 0 ≤ p ≤ 1 |
n
is an integer parameter that counts the number of independent Bernoulli trials.
| Range | n = 1, 2, ... |
Cauchy Distribution
Chi-Square Distribution
Erlang Distribution
Exponential Distribution
x
σ
is a numeric constant, variable, or expression that specifies a shape parameter.
| Default | The optional shape parameter σ > 0 has the default value σ = 1. |
F Distribution
x
n
is a numeric constant, variable, or expression that specifies the numerator degrees of freedom.
| Range | n > 0 |
d
is a numeric constant, variable, or expression that specifies the denominator degrees of freedom.
| Range | d > 0 |
Gamma Distribution
x
a
is a numeric constant, variable, or expression that specifies a shape parameter.
| Range | a > 0 |
λ
is a numeric constant, variable, or expression that specifies a shape parameter.
| Default | The optional shape parameter λ > 0 has the default value λ = 1. |
Geometric Distribution
x
p
is a numeric constant, variable, or expression that specifies the probability of success.
| Range | 0 < p ≤ 1 |
Hypergeometric Distribution
x
N
is a numeric constant, variable, or expression that specifies an integer population size parameter.
| Range | N = 1, 2, ... |
R
is a numeric constant, variable, or expression that specifies an integer number of items in the category of interest.
| Range | R = 0, 1, ..., N |
n
is a numeric constant, variable, or expression that specifies an integer sample size parameter.
| Range | n = 1, 2, ..., N |
Lognormal Distribution
x
θ
is a numeric constant, variable, or expression that specifies a shape parameter.
| Default | The optional log-scale parameter θ has the default value θ = 0. |
λ
is a numeric constant, variable, or expression that specifies a shape parameter.
| Default | The optional log-scale parameter λ has the default value λ = 1. |
Negative Binomial Distribution
x
k
is an integer parameter that is the number of successes. However, noninteger k values are allowed as well.
| Range | k = 1, 2, ... |
p
is a numeric constant, variable, or expression that specifies the probability of success.
| Range | 0 < p ≤ 1 |
Normal Distribution
x
θ
is a numeric constant, variable, or expression that specifies a mean parameter.
| Default | 0 |
λ
is a numeric constant, variable, or expression that specifies a standard deviation parameter.
| Default | 1 |
| Range | λ > 0 |
Poisson Distribution
T Distribution
Tabled Distribution
x
p1, p2, ...
are numeric probability values.
| Range | 0 ≤ p1, p2, ... ≤ 1 |
| Restriction | The maximum number of probability parameters depends on your operating environment, but the maximum number of parameters is at least 32,767. |
Triangular Distribution
x
h
is a numeric constant, variable, or expression that specifies the horizontal location of the peak of the triangle.
| Range | 0 ≤ h ≤ 1 |
Uniform Distribution
x
is an observation from the distribution with the following probability density function:

| Range | The range of x is a ≤ x ≤b. The parameters a and b default values are a=0 and b=1. You must specify values for both a and b if you do not want to use the default values. |
a
specifies a value in the probability density function.
| Default | 0 |
b
specifies a value in the probability density function.
| Default | 1 |
Weibull Distribution
x
a
is a numeric constant, variable, or expression that specifies a shape parameter.
| Range | a > 0 |
b
is a numeric constant, variable, or expression that specifies a scale parameter.
| Range | b > 0 |
Example
|
SAS Statement
|
Result
|
|---|---|
x=rand('BERN', .75); |
0 |
x=rand('BETA', 3, 0.1); |
.99920 |
x=rand('BINOM', 0.75, 10); |
10 |
x=rand('CAUCHY'); |
-1.41525 |
x=rand('CHISQ', 22); |
25.8526 |
x=rand('ERLANG', 7); |
7.67039 |
x=rand('EXPO'); |
1.48847 |
x=rand('F', 12, 322); |
1.99647 |
x=rand('GAMMA', 7.25); |
6.59588 |
x=rand('GEOM', 0.02); |
43 |
x=rand('HYPER', 10, 3, 5); |
1 |
x=rand('LOGN'); |
0.66522 |
x=rand('NEGB', 0.8, 5); |
33 |
x=rand('NORMAL'); |
1.03507 |
x=rand('POISSON', 6.1); |
6 |
x=rand('T', 4); |
2.44646 |
x=rand('TABLE', .2, .5); |
2 |
x=rand('TRIANGLE', 0.7); |
.63811 |
x=rand('UNIFORM'); |
.96234 |
x=rand('WEIB', 0.25, 2.1); |
6.55778 |