Generate random numbers from specified distribution, parameters, and initial seed
Generators / Signal Generators
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.
$$f(x)=\{\begin{array}{ll}\frac{1}{\mu}\mathrm{exp}\left(-\frac{x}{\mu}\right)\hfill & \text{for}x\ge 0\hfill \\ 0\hfill & \text{otherwise}\hfill \end{array}$$
where μ is the Mean parameter, a positive number.
A similar function in the Statistics and Machine Learning Toolbox™ software is exprnd
.
$$f(x)=\{\begin{array}{ll}\frac{1}{U-L}\hfill & \text{for}L\le x\le U\hfill \\ 0\hfill & \text{otherwise}\hfill \end{array}$$
where L is the Minimum parameter and U is the Maximum parameter.
Similar functions are rand
in MATLAB^{®} software
and unifrnd
in the Statistics and Machine Learning Toolbox software.
$$f(x)=\{\begin{array}{ll}{p}^{x}{(1-p)}^{1-x}\hfill & \text{for}x=0,1\hfill \\ 0\hfill & \text{otherwise}\hfill \end{array}$$
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.
$$f(x)=\{\begin{array}{ll}\frac{n!}{x!(n-x)!}{p}^{x}{q}^{(n-x)}\hfill & \text{for}x=0,1,2,\mathrm{...},n\hfill \\ 0\hfill & \text{otherwise}\hfill \end{array}$$
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 and Machine Learning Toolbox software is binornd
.
$$f(x)=\{\begin{array}{ll}\frac{2(x-L)}{(U-L)(m-L)}\hfill & \text{for}L\le x\le m\hfill \\ \frac{2(U-x)}{(U-L)(U-m)}\hfill & \text{for}mx\le U\hfill \\ 0\hfill & \text{otherwise}\hfill \end{array}$$
where L is the Minimum parameter, U is the Maximum parameter, and m is the Mode parameter. These parameters must satisfy L < m < U.
$$f(x)=\{\begin{array}{ll}\frac{{\left(\frac{x-\theta}{b}\right)}^{a-1}\mathrm{exp}\left(-\frac{x-\theta}{b}\right)}{b\Gamma (\gamma )}\hfill & \text{for}x\ge \theta \hfill \\ 0\hfill & \text{otherwise}\hfill \end{array}$$
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 and Machine Learning Toolbox software is gamrnd
.
$$f(x)=\frac{\mathrm{exp}\left(-{(x-\mu )}^{2}/(2{\sigma}^{2})\right)}{\sigma \sqrt{2\pi}}$$
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 and Machine Learning 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
$$f(x)=\{\begin{array}{ll}p{q}^{x}\hfill & \text{for}x=0,1,2,\mathrm{...}\hfill \\ 0\hfill & \text{otherwise}\hfill \end{array}$$
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
$$f(x)=\{\begin{array}{ll}1\hfill & \text{for}x=0\hfill \\ \text{0}\hfill & \text{otherwise}\hfill \end{array}$$
This is a discrete distribution.
A similar function in the Statistics and Machine Learning Toolbox software is geornd
.
$$f(x)=\{\begin{array}{ll}\frac{{e}^{-\lambda}{\lambda}^{x}}{x!}\hfill & \text{for}x=0,1,2,\mathrm{...}\hfill \\ 0\hfill & \text{otherwise}\hfill \end{array}$$
where λ is the Mean parameter, a positive number. This is a discrete distribution.
A similar function in the Statistics and Machine Learning Toolbox software is poissrnd
.
$$f(x)=\{\begin{array}{ll}\frac{\mathrm{exp}\left[\frac{-{\left(\mathrm{ln}\left(x-\theta \right)-\mu \right)}^{2}}{2{\sigma}^{2}}\right]}{(x-\theta )\sigma \sqrt{2\pi}}\hfill & \text{for}x\ge \theta \hfill \\ 0\hfill & \text{otherwise}\hfill \end{array}$$
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 and Machine Learning 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
$${f}_{\text{logistic}}(x)=\frac{1}{b}\cdot \frac{{e}^{(x-\theta )/b}}{{\left(1+{e}^{(x-\theta )/b}\right)}^{2}}$$
where θ is the Threshold parameter and b is the Scale parameter. The Scale parameter must be positive.
$$f(x)=\{\begin{array}{ll}\frac{{(x-L)}^{a-1}{(U-x)}^{b-1}}{B(a,b){(U-L)}^{a+b+1}}\hfill & \text{for}L\le x\le U\hfill \\ 0\hfill & \text{otherwise}\hfill \end{array}$$
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
$$B(a,b)={\displaystyle {\int}_{0}^{1}{t}^{a-1}{(1-t)}^{b-1}dt}$$
The two shape parameters must be positive.
A similar function in the Statistics and Machine Learning Toolbox software is betarnd
.
$$f(x)=\{\begin{array}{ll}1/K\hfill & \text{for}x=L+k\frac{(U-L)}{K-1}\text{,}k=0,1,2,\mathrm{...},K-1\hfill \\ 0\hfill & \text{otherwise}\hfill \end{array}$$
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 and Machine Learning Toolbox software.
$$f(x)=\{\begin{array}{ll}\frac{\gamma}{\alpha}{\left(\frac{x-\theta}{\alpha}\right)}^{(\gamma -1)}\mathrm{exp}\left[-{\left(\frac{x-\theta}{\alpha}\right)}^{\gamma}\right]\hfill & \text{for}x\ge \theta \hfill \\ 0\hfill & \text{otherwise}\hfill \end{array}$$
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 and Machine Learning 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.