Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Event-Based Random Number

Generate random numbers from specified distribution, parameters, and initial seed

Library

Generators / Signal Generators

Description

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.

Connecting to Other Blocks

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 PortExact Number of Connections
Notifying Ports1
Reactive Ports

0

Monitoring PortsArbitrary number
Ports of blocks that appear in Sink BlocksArbitrary number

All indirect connections must be via blocks that have all of the following characteristics:

    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.

Distribution Types

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.

DistributionAdditional Parameters
ExponentialMean
UniformMinimum, Maximum
BernoulliProbability of 1
BinomialProbability of success in a single trial, Number of trials
TriangularMinimum, Maximum, Mode
GammaThreshold, Scale, Shape
Gaussian (normal)Mean, Standard deviation
GeometricProbability of success in a single trial
PoissonMean
LognormalThreshold, Mu, Sigma
Log-logisticThreshold, Scale
BetaMinimum, Maximum, Shape parameter a, Shape parameter b
Discrete uniformMinimum, Maximum, Number of values
WeibullThreshold, Scale, Shape
Arbitrary continuousValue vector, Cumulative probability function vector
Arbitrary discreteValue vector, Probability vector

For information about the definitions and properties of each distribution, see References below.

Range of Output Values

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.

Ports

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.

Dialog Box

Distribution

The distribution from which the block generates random numbers.

Mean

The mean value of an exponential, Gaussian, or Poisson distribution.

Minimum

The minimum value of a uniform, triangular, beta, or discrete uniform distribution.

Maximum

The maximum value of a uniform, triangular, beta, or discrete uniform distribution.

Probability for output to be 1

The probability of a one in a Bernoulli distribution.

Probability of success in a single trial

The probability of a successful outcome in each trial used to describe a binomial or geometric distribution.

Number of trials

The number of trials used to describe a binomial distribution.

Mode

The statistical mode of a triangular distribution. The triangular distribution also uses the Minimum and Maximum parameters to define its density function.

Threshold, Scale, Shape

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.

Threshold, Mu, Sigma

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.

Standard deviation

The standard deviation of a Gaussian distribution, which also uses the Mean parameter to define its density function.

Shape parameter a, Shape parameter b

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.

Number of values

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.

Value vector

A vector of values in ascending order, representing the possible random values in an arbitrary continuous or arbitrary discrete distribution.

Cumulative probability function vector

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.

Probability vector

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.

Initial seed

A nonnegative integer that initializes the random number generator.

Algorithm

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.

Exponential Distribution

where μ is the Mean parameter, a positive number.

A similar function in the Statistics Toolbox™ software is exprnd.

Uniform Distribution

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.

Bernoulli Distribution

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.

Binomial Distribution

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.

Triangular Distribution

where L is the Minimum parameter, U is the Maximum parameter, and m is the Mode parameter. These parameters must satisfy L < m < U.

Gamma Distribution

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.

Gaussian (Normal) Distribution

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.

Geometric Distribution

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.

Poisson Distribution

where λ is the Mean parameter, a positive number. This is a discrete distribution.

A similar function in the Statistics Toolbox software is poissrnd.

Lognormal Distribution

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.

Log-Logistic Distribution

The log-logistic distribution is derived from the logistic distribution, as follows:

X = Random variable with logistic distribution

Y = eX = 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.

Beta Distribution

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.

Discrete Uniform Distribution

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.

Weibull Distribution

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.

References

[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.

Was this topic helpful?