Learn R Programming

MPkn (version 0.1.0)

MUPkL: Calculations of one discrete model in several time steps

Description

M[i + 1] = (I + Q) * M[i] process in several selected steps. \(Q = P * U\), matrix multiplication. Computation process only in the following steps i:

\(c(1:k, k * 2^(1:(n-k)))\) where k > 1;
\(c(2^((1:n)-1))\) for k == 0;

\(M[2*i] = (I + Q^i) * M[i]\) for k == 0.

Usage

MUPkL(A, P, U, n, k, sta)

Arguments

A

starting square matrix a process at time 0

P

basic transition matrix chain

U

correction matrix chain

n

The number of steps. The length of the steps depends on the value of k.

k

k == 0 ... step length i is equal to \(2^(i-1), i = 1, 2, .. , n\). k == 1 ... step length i is equal to 1. k > 1 ... The first n steps has a length equal to 1. Other then have a length of twice the previous step.

sta

Vector whose values are the indices of the columns of the A matrix.

Value

A list with following components:

N sum values of entries into state
Navg average N in interval (i - 1, i]
Tavg \(1/Navg\)

Details

Both n and k are single positive integers.

Examples

Run this code
# NOT RUN {
A <- array(c(2, 3, 1, 4, 2, 1, 3, 1, 2), c(3, 3))
P <- array(c(0.9, 0.6, 0.8, 0.05, 0.2, 0.05, 0.05, 0.2, 0.15),
					 c(3, 3))
U <- array(c(0.8, 0.8, 0.7, 0.06, 0.02, 0.2, 0.14, 0.18, 0.1),
					 c(3, 3))
sta <- c(1, 3)
k <- 3
n <- 8
M33 <- MUPkL(A, P, U, n, k, sta)
print(M33$N)
k <- 1
n <- 24
M11 <- MUPkL(A, P, U, n, k, sta)
print(M11$N)
k <- 0
n <- 6
M00 <- MUPkL(A, P, U, n, k, sta)
print(M00$N)
# }

Run the code above in your browser using DataLab