rstochmat: Random Generation of Stochastic Matrices

View source: R/randmat.R

rstochmatR Documentation

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.

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.

Value

An n\times n stochastic matrix with rows and columns labelled according to ‘⁠labels⁠’.

Author(s)

Andrew Hart and Servet Martínez

See Also

rcspr2mat, estimateMarkovChain, simulateMarkovChain

Examples

rstochmat(4)
rstochmat(3, c("a", "b", "c"))
rstochmat(labels=c("r", "R"))

spgs documentation built on Oct. 3, 2023, 5:07 p.m.