RM_stoch: Generate a random stochastic matrix

Description Usage Arguments Value Examples

View source: R/matrices.R

Description

A (row-)stochastic matrix is a matrix whose rums sum to 1. There is a natural one-to-one corrospondence between stochastic matrices and Markov Chains; this is so when its i,j entry represent the transition probability from state i to state j.

Usage

1
RM_stoch(N, symm = FALSE, sparsity = FALSE)

Arguments

N

number of dimensions of the square matrix

symm

indicates whether the matrix should be symmetric; equal to its transpose.

sparsity

indicates whether the matrix should add some arbitrary sparsity (zeros)

Value

A random stochastic matrix.

Examples

1
2
3
4
P <- RM_stoch(N = 3)
P <- RM_stoch(N = 9, sparsity = TRUE)
Q <- RM_stoch(N = 9, symm = TRUE)
Q <- RM_stoch(N = 9, symm = TRUE, sparsity = TRUE)

RMAT documentation built on April 28, 2021, 9:06 a.m.