DSP Blockset    
Random Source

Generate randomly distributed values.

Library

DSP Sources

Description

The Random Source block generates a frame of M values drawn from a uniform or Gaussian pseudorandom distribution, where M is specified by the Samples per frame parameter.

Distribution Type

When the Source type parameter is set to Uniform, the output samples are drawn from a uniform distribution whose minimum and maximum values are specified by the Minimum and Maximum parameters, respectively. All values in this range are equally likely to be selected. A length-N vector specified for one or both of these parameters generates an N-channel output (M-by-N matrix) containing a unique random distribution in each channel.

For example, specify

to generate a four-channel output whose first and second columns contain random values in the range [0, 10], and whose third and fourth columns contain random values in the range [-3, 20]. When only one of the Minimum and Maximum parameters is specified as a vector, the other is scalar expanded to the same length.

When the Source type parameter is set to Gaussian, the output samples are drawn from the normal distribution defined by the Mean and Variance parameters. A length-N vector specified for one or both of the Mean and Variance parameters generates an N-channel output (M-by-N frame matrix) containing a distinct random distribution in each column. When only one of these parameters is specified as a vector, the other is scalar expanded to the same length.

Output Data Type

The block's output can be either real or complex, as selected by the Real and Complex options in the Output complexity parameter. (These settings control all channels of the output, so real and complex data cannot be combined in the same output.) For complex output with a Uniform distribution, the real and imaginary components in each channel are both drawn from the same uniform random distribution, defined by the Minimum and Maximum parameters for that channel.

For complex output with a Gaussian distribution, the real and imaginary components in each channel are drawn from normal distributions with different means. In this case, the Mean parameter for each channel should specify a complex value; the real component of the Mean parameter specifies the mean of the real components in the channel, while the imaginary component specifies the mean of the imaginary components in the channel. If either the real or imaginary component is omitted from the Mean parameter, a default value of 0 is used for the mean of that component.

For example, a Mean parameter setting of [5+2i 0.5 3i] generates a three-channel output with the following means.

Channel 1 mean
real = 5
imaginary = 2
Channel 2 mean
real = 0.5
imaginary = 0
Channel 3 mean
real = 0
imaginary = 3

For complex output, the Variance parameter, 2, specifies the total variance for each output channel. This is the sum of the variances of the real and imaginary components in that channel.

The specified variance is equally divided between the real and imaginary components, so that

Initial Seed

The Initial seed parameter specifies the initial seed for the pseudorandom number generator. The generator produces an identical sequence of pseudorandom numbers each time it is executed with a particular initial seed.

For real outputs (Output complexity parameter set to Real), a length-N seed vector can be specified to set a distinct initial generator seed for each individual channel. When a scalar seed is specified for a multichannel output, the block uses the specified seed for the first channel, and increments the seed by 2 for each additional channel. For example, specifying an Initial seed value of 10 for a five-channel output is equivalent to specifying an Initial seed vector of [10 12 14 16 18].

For complex outputs (Output complexity parameter set to Complex), a length-N seed vector can be specified to set a distinct initial generator seed to be used for the real components of each individual channel. The block increments these values by 1 to determine the initial seeds used for the imaginary components of the corresponding channels.

When a scalar seed is specified for a multichannel complex output, the block uses the specified seed for the real components of the first channel, and increments the seed by 2 for the real components of each additional channel. The block increments the specified seed by 1 for the imaginary components of the first channel, and increments the first channel's imaginary seed by 2 for the imaginary components of each additional channel. For example, specifying an Initial seed value of 10 for a five-channel complex output is equivalent to specifying an Initial seed vector of [10 12 14 16 18]. These values are used to seed the real-component generator for each channel; the vector [11 13 15 17 19] is used to seed the imaginary-component generator for each channel.

Sample Period

The Sample time parameter value, Ts, specifies the random sequence sample period when the Sample mode parameter is set to Discrete. In this mode, the block generates the number of samples specified by the Samples per frame parameter value, M, and outputs this frame with a period of M*Ts. For M=1, the output is sample-based; otherwise, the output is frame-based.

When Sample mode is set to Continuous, the block is configured for continuous-time operation, and the Sample time and Samples per frame parameters are disabled. Note that many blocks in the DSP Blockset do not accept continuous-time inputs.

Dialog Box

Source type
The distribution from which to draw the random values, Uniform or Gaussian.
Minimum
The minimum value in the uniform distribution. This parameter is only enabled when Uniform is selected from the Source type parameter. Tunable.
Maximum
The maximum value in the uniform distribution. This parameter is only enabled when Uniform is selected from the Source type parameter. Tunable.
Mean
The mean of the Gaussian (normal) distribution. This parameter is only enabled when Gaussian is selected from the Source type parameter. Tunable.
Variance
The variance of the Gaussian (normal) distribution. This parameter is only enabled when Gaussian is selected from the Source type parameter. Tunable.
Initial seed
The initial seed(s) to use for the random number generator.
Inherit output port attributes
When selected, allows the block to inherit the sample mode, sample period, and complexity of a downstream block. (The Sample mode, Sample time, Samples per frame, and Output complexity parameters are disabled.) The output is a length-M sample-based 1-D vector, where length M is inherited from the downstream block. If the Minimum, Maximum, Mean, or Variance parameter specifies N channels, the 1-D vector output contains M/N samples from each channel. An error occurs in this case if M is not an integer multiple of N.
Sample mode
The sample mode, Continuous or Discrete. This parameter is enabled when the Inherit output port attributes check box is deselected.
Sample time
The sample period, Ts, of the random output sequence. The output frame period is M*Ts. This parameter is enabled when the Inherit output port attributes check box is deselected.
Samples per frame
The number of samples, M, in each output frame. This parameter is enabled when the Inherit output port attributes check box is deselected.
Output complexity
The data type of the output, Real or Complex. This parameter is enabled when the Inherit output port attributes check box is deselected.

See Also

Discrete Impulse
DSP Blockset
DSP Constant
DSP Blockset
Maximum
DSP Blockset
Minimum
DSP Blockset
Random Number
Simulink
Signal From Workspace
DSP Blockset
Signal Generator
Simulink
Standard Deviation
DSP Blockset
Variance
DSP Blockset
rand
MATLAB
randn
MATLAB

See Creating Signals Using Signal Generator Blocks for related information.


 Queue Real Cepstrum