mc.create: mc.create

Description Usage Arguments Value Examples

View source: R/create.R

Description

Create an appropriate markov chain object

Usage

1
mc.create(pijdef, stateNames=NULL, chainName=NULL, qidef=NULL, discrete, infinite, use_ratematrix)

Arguments

pijdef

Transition matrix definition. Can be a matrix or a function with input(i,j) and output P(i to j).

stateNames

Names of states. Default to NULL, which forces the names to be 1 to n.

chainName

Name of the markov chain. Default to NULL.

qidef

A vector of holding time distribution parameters. Must have for continuous markov chain.

discrete

A logical value indicating if the markov chain is discrete (FALSE means continuous).

infinite

A logical value indicating if the markov chain is infinite (FALSE means finite).

use_ratematrix

If you wish to solve the problem with a matrix.

Value

returns an appropriate markov chain object

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
# discrete finite
threeHeads = function(){
  p = matrix(0, nrow=3, ncol=3)
  p[1, c(1,2)] = 0.5
  p[2, c(1,3)] = 0.5
  p[3, 1] = 1
  return(p)
}
ex = mc.create(pijdef = threeHeads(), discrete = TRUE, infinite = FALSE)

# discrete infinite 
singleServer = function(i,j){
  p = 0.3
  q = 0.7
  r = 0
  if(j == i+1)
    return(p)
  if(j == i-1)
    return(q)
  if(j==i)
    return(r)
  return(0)
}
ex = mc.create(pijdef=singleServer, discrete=TRUE, infinite=TRUE)

qiwei-li/infiniteMC documentation built on May 26, 2019, 11:36 a.m.