Documentation

randerr

Generate bit error patterns

Syntax

out = randerr(m)
out = randerr(m,n)
out = randerr(m,n,errors)
out = randerr(m,n,prob,state)
out = randerr(m,n,prob,s)

Description

For all syntaxes, randerr treats each row of out independently.

out = randerr(m) generates an m-by-m binary matrix, each row of which has exactly one nonzero entry in a random position. Each allowable configuration has an equal probability.

out = randerr(m,n) generates an m-by-n binary matrix, each row of which has exactly one nonzero entry in a random position. Each allowable configuration has an equal probability.

out = randerr(m,n,errors) generates an m-by-n binary matrix, where errors determines how many nonzero entries are in each row:

  • If errors is a scalar, it is the number of nonzero entries in each row.

  • If errors is a row vector, it lists the possible number of nonzero entries in each row.

  • If errors is a matrix having two rows, the first row lists the possible number of nonzero entries in each row and the second row lists the probabilities that correspond to the possible error counts.

Once randerr determines the number of nonzero entries in a given row, each configuration of that number of nonzero entries has equal probability.

out = randerr(m,n,prob,state) is the same as the syntax above, except that it first resets the state of the uniform random number generator rand to the integer state.

    Note:   This usage is deprecated and may be removed in a future release. Instead of state, use s, as in the following example.

This function uses, by default, the Mersenne Twister algorithm by Nishimura and Matsumoto.

    Note:   Using the state parameter causes this function to switch random generators to use the 'state' algorithm of the rand function.

    See rand for details on the generator algorithm.

out = randerr(m,n,prob,s) causes rand to use the random stream s. See RandStream for more details.

Examples

The examples below generate an 8-by-7 binary matrix, each row of which is equally likely to have either zero or two nonzero entries, and then alter the scenario by making it three times as likely that a row has two nonzero entries. Notice in the latter example that the second row of the error parameter sums to one.

out = randerr(8,7,[0 2])

out2 = randerr(8,7,[0 2; .25 .75])

Sample output is below.

out =

     0     0     0     0     0     0     0
     0     0     0     0     0     0     0
     0     0     1     0     0     0     1
     1     0     1     0     0     0     0
     0     0     0     0     0     0     0
     0     0     0     0     0     0     0
     0     0     0     0     1     1     0
     1     0     1     0     0     0     0


out2 =

     0     0     0     0     0     0     0
     1     0     0     0     0     0     1
     1     0     0     0     0     0     1
     0     0     0     1     0     1     0
     0     0     0     0     0     0     0
     0     1     0     0     0     0     1
     0     0     0     0     0     0     0
     1     0     0     0     1     0     0

See Also

| |

Was this topic helpful?