Learn R Programming

spgs (version 1.0-1)

rstochmat: Random Generation of Stochastic Matrices

Description

Randomly generates stochastic matrices.

Usage

rstochmat(n, labels)

Arguments

n

the dimension of the matrix. If n is not specified, it is inferred from the lenth of labels.

labels

a vector of labels for the rows and columns of the matrix. If labels is not specified, n must be specified and the value as.character(1:n) is assumed.

Value

An \(n\times n\) stochastic matrix with rows and columns labelled according to labels.

Details

Stochastic matrices are non-negative matrices whose rows all sum to unity. This function uniformly generates samples from the set of \(n\times n\) stochastic matrices.

At least one of the arguments must be specified. The missing argument is infered from the other.

See Also

rcspr2mat, estimateMarkovChain, simulateMarkovChain

Examples

Run this code
# NOT RUN {
rstochmat(4)
rstochmat(3, c("a", "b", "c"))
rstochmat(labels=c("r", "R"))
# }

Run the code above in your browser using DataLab