Documentation Center |
Generate random numbers from specified distribution, parameters, and initial seed
This block generates random numbers in an event-based manner, inferring from a subsequent block when to generate a new random number. For example, when connected to the t input port of a Single Server block, the Event-Based Random Number block generates a new random number each time an entity arrives at the server.
You specify the distribution from which the block draws random numbers. The seed of the random number generator is reset to the value of the Initial seed parameter each time a simulation starts, which makes the random behavior repeatable.
This block has a restricted set of valid connections to other blocks because the Event-Based Random Number block infers from a subsequent block when to generate a new random number.
The direct or indirect connections to signal input ports must have the multiplicities in the table.
Type of Signal Input Port | Exact Number of Connections | |
---|---|---|
Notifying Ports | 1 | |
Reactive Ports | 0
| |
Monitoring Ports | Arbitrary number | |
Ports of blocks that appear in Sink Blocks | Arbitrary number |
All indirect connections must be via blocks that have all of the following characteristics:
Appears in Computational Blocks
Has exactly one input signal
Has no function-call output signals
Tip For an indirect connection to the Atomic Subsystem block, the restrictions on input and output signals apply to the subsystem itself, not the blocks inside the subsystem. |
The Distribution parameter names the type of distribution the block uses to generate random numbers. When you set the Distribution parameter, the block changes its dialog box to show additional parameters that determine the probability density function (or probability mass function, for a discrete distribution). The available distributions and the additional parameters for each are described in the sections that follow.
Distribution | Additional Parameters |
---|---|
Exponential | Mean |
Uniform | Minimum, Maximum |
Bernoulli | Probability of 1 |
Binomial | Probability of success in a single trial, Number of trials |
Triangular | Minimum, Maximum, Mode |
Gamma | Threshold, Scale, Shape |
Gaussian (normal) | Mean, Standard deviation |
Geometric | Probability of success in a single trial |
Poisson | Mean |
Lognormal | Threshold, Mu, Sigma |
Log-logistic | Threshold, Scale |
Beta | Minimum, Maximum, Shape parameter a, Shape parameter b |
Discrete uniform | Minimum, Maximum, Number of values |
Weibull | Threshold, Scale, Shape |
Arbitrary continuous | Value vector, Cumulative probability function vector |
Arbitrary discrete | Value vector, Probability vector |
For information about the definitions and properties of each distribution, see References below.
Different distributions have different output ranges. Make sure the distribution and parameters you choose are suitable for your application. For example, when generating random service times, do not use a Gaussian distribution because it can produce negative numbers.
This block has one signal output port for the random numbers. The initial output value is 0. This value is in effect from the start of the simulation until the first update by the block.
The block has no entity ports, and no signal input port.
The distribution from which the block generates random numbers.
The mean value of an exponential, Gaussian, or Poisson distribution.
The minimum value of a uniform, triangular, beta, or discrete uniform distribution.
The maximum value of a uniform, triangular, beta, or discrete uniform distribution.
The probability of a one in a Bernoulli distribution.
The probability of a successful outcome in each trial used to describe a binomial or geometric distribution.
The number of trials used to describe a binomial distribution.
The statistical mode of a triangular distribution. The triangular distribution also uses the Minimum and Maximum parameters to define its density function.
Parameters that define the density function of a gamma, log-logistic, or Weibull distribution. The log-logistic distribution does not use a Shape parameter, however.
Parameters that define the density function of a lognormal distribution. The log of a lognormal random variable is normally distributed with mean Mu and standard deviation Sigma.
The standard deviation of a Gaussian distribution, which also uses the Mean parameter to define its density function.
The first and second shape parameters, respectively, of a beta distribution. The beta distribution also uses the Minimum and Maximum parameters to define its density function.
The number of possible outputs of a discrete uniform distribution, including the values of the Minimum and Maximum parameters. Number of values must exceed 1.
A vector of values in ascending order, representing the possible random values in an arbitrary continuous or arbitrary discrete distribution.
A vector of values in ascending order representing the cumulative probability function for an arbitrary continuous distribution. The first and last values of the vector must be 0 and 1, respectively. This parameter and the Value vector parameter must have the same vector length.
A vector of values representing the probability of each value in the Value vector function for an arbitrary discrete distribution. This vector must contain nonnegative values that sum to 1. This parameter and the Value vector parameter must have the same vector length.
A nonnegative integer that initializes the random number generator.
Below are the expressions for f, the probability density functions for the continuous distributions and probability mass functions for the discrete distributions that the block supports.
where μ is the Mean parameter, a positive number.
A similar function in the Statistics Toolbox™ software is exprnd.
where L is the Minimum parameter and U is the Maximum parameter.
Similar functions are rand in MATLAB^{®} software and unifrnd in the Statistics Toolbox software.
where p is the Probability of 1 parameter. The value p must be between 0 and 1, inclusive. This is a discrete distribution.
This distribution is a special case of the binomial distribution in which the number of trials is 1.
where p is the Probability of success in a single trial parameter, q = 1–p, and n is the Number of trials parameter. The value p must be between 0 and 1, inclusive, while n must be positive. This is a discrete distribution.
A similar function in the Statistics Toolbox software is binornd.
where L is the Minimum parameter, U is the Maximum parameter, and m is the Mode parameter. These parameters must satisfy L < m < U.
where θ is the Threshold parameter, b is the Scale parameter, and a is the Shape parameter. The Scale and Shape parameters must be positive. Also, Γ is the gamma function (gamma in MATLAB code).
A similar function in the Statistics Toolbox software is gamrnd.
where μ is the Mean parameter and σ is the Standard deviation parameter. The standard deviation parameter must be nonnegative.
Similar functions are randn in MATLAB software and normrnd in the Statistics Toolbox software.
If the Probability of success in a single trial parameter is strictly between 0 and 1, then the probability mass function is defined by
where p is the Probability of success in a single trial parameter and q = 1–p.
In the special case where the Probability of success in a single trial parameter is 1, then
This is a discrete distribution.
A similar function in the Statistics Toolbox software is geornd.
where λ is the Mean parameter, a positive number. This is a discrete distribution.
A similar function in the Statistics Toolbox software is poissrnd.
where θ is the Threshold parameter, μ is the Mu parameter, and σ is the Sigma parameter. The Sigma parameter must be positive.
A similar function in the Statistics Toolbox software is lognrnd.
The log-logistic distribution is derived from the logistic distribution, as follows:
X = Random variable with logistic distribution
Y = e^{X} = Random variable with log-logistic distribution
The probability density function for the logistic distribution is
where θ is the Threshold parameter and b is the Scale parameter. The Scale parameter must be positive.
where L is the Minimum parameter, M is the Maximum parameter, a is the Shape parameter a parameter, b is the Shape parameter b parameter, and B(a,b) is the beta function defined by
The two shape parameters must be positive.
A similar function in the Statistics Toolbox software is betarnd.
where L is the Minimum parameter, U is the Maximum parameter, and K is the Number of values parameter. This is a discrete distribution. If (U-L)/(K-1) and L are both integers, then all outputs from this distribution are integers.
Similar functions are randi in MATLAB software and unidrnd in the Statistics Toolbox software.
where θ is the Threshold parameter, α is the Scale parameter, and γ is the Shape parameter. The Scale and Shape parameters must be positive.
A similar function in the Statistics Toolbox software is wblrnd.
[1] Evans, M., N. Hastings, and B. Peacock. Statistical Distributions. Wiley-Interscience, 2000.
[2] Johnson, N. L., S. Kotz, and N. Balakrishnan. Continuous Univariate Distributions, Volume 1. Wiley-Interscience, 1993.
[3] Johnson, N. L., S. Kotz, and N. Balakrishnan. Continuous Univariate Distributions, Volume 2. Wiley-Interscience, 1994.
[4] Johnson, N. L., S. Kotz, and A. W. Kemp. Univariate Discrete Distributions. Wiley-Interscience, 1993.