Random Bit Error Patterns
The randerr function generates matrices
whose entries are either 0 or 1. However, its options are different
from those of randint, because randerr is meant for testing error-control coding. For example, the command
below generates a 5-by-4 binary matrix, where each row contains exactly
one 1.
f = randerr(5,4)
f =
0 0 1 0
0 0 1 0
0 1 0 0
1 0 0 0
0 0 1 0
You might use such a command to perturb a binary code that consists
of five four-bit codewords. Adding the random matrix f to your code matrix (modulo 2) introduces exactly one error into
each codeword.
On the other hand, to perturb each codeword by introducing one
error with probability 0.4 and two errors with probability 0.6, use
the command below instead.
% Each row has one '1' with probability 0.4, otherwise two '1's
g = randerr(5,4,[1,2; 0.4,0.6])
g =
0 1 1 0
0 1 0 0
0 0 1 1
1 0 1 0
0 1 1 0
Note
The probability matrix that is the third argument of randerr affects only the number of
1s in each row, not their placement. |
As another application, you can generate an equiprobable binary
100-element column vector using any of the commands below. The three
commands produce different numerical outputs, but use the same distribution. The third input arguments vary according
to each function's particular way of specifying its behavior.
binarymatrix1 = randsrc(100,1,[0 1]); % Possible values are 0,1.
binarymatrix2 = randint(100,1,2); % Two possible values
binarymatrix3 = randerr(100,1,[0 1;.5 .5]); % No 1s, or one 1
 | Random Integers | | Performance Evaluation |  |
How much time do you spend on testing to ensure implementation meets system-level requirements?
Learn more