hittingtime.dtmc: Calculate the Submatrix of Expected Hitting Times

Description Usage Arguments Details Value Author(s) Examples

View source: R/hittingtime.dtmc.R

Description

Calculate the submatrix of expected hitting times, with rows and columns specified by the user.

Usage

1
2
3
4
## S3 method for class 'dtmc'
hittingtime(obj, i, j, k = 10, epsilon = 0.05)
## S3 method for class 'ctmc'
hittingtime(obj, i, j, k = 10, epsilon = 0.05)

Arguments

obj

the Markov Chain we want to apply

i

user defined rows of the submatrix

j

user defined columns of the submatrix

k

for infinite state Markov Chain, the initial state to do the iterative process in order to find the stationary distribution, default value is 10

epsilon

for infinite state Markov Chain, the convergence criterion to stop the iterative process, default value is 0.05

Details

pijdef can either be in the matrix form or in the function form.

Value

A matrix corresponding to the expected hitting times

Author(s)

Jiexuan Cao, Yuki Liu, Qianhan Zhang

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
dtftmc = mc(states = c("sunny", "cloudy", "rain"),
                 pijdef = function(i,j,...) {
                           if (i == 1 && j < 3 ||
                               i == 2 && j != 2 ||
                               i == 3 && j > 1)  return(0.5)
                           0
                        },  
       name = "Weather")

dtftht = hittingtime(dtftmc, c(1,2), c(1,3))


pijdeffunction = function(i,j) {
    p = 0.3
    q = 0.7
    r = 0
    if (i == 1 && j == 1)
        return (1 - p)
    if(j == i + 1)
        return(p)
    if(j == i - 1)
        return(q)
    if(j==i)
        return(r)
    return(0)
}

dtiftmc = mc(states = "infinity",
             pijdef = pijdeffunction, 
             name = "death and birth")

dtiftht = hittingtime(dtiftmc, c(1,2), c(1,3))

ctftmc = mc(states = c("0", "1", "2"),
            pijdef = matrix(c(0, 0.2857143, 0, 1, 0, 1, 0, 0.7142857, 0), ncol = 3),
            qidef = c(0.25, 0.175, 0.08),
            name = 'Machine Repair')
            
hittingtime(ctftmc, c(1,2), c(2,3))

yuki0425/mc documentation built on May 4, 2019, 7:44 p.m.