View source: R/fittingFunctions.R
| noofVisitsDist | R Documentation |
Given the initial state i, returns for every state
j the expected fraction of the first N steps that the DTMC
spends in j.
noofVisitsDist(markovchain,N,state)
markovchain |
a markovchain-class object |
N |
number of steps, a positive integer |
state |
the initial state |
The value for state j is
\frac{1}{N}\sum_{k=1}^{N} (P^k)_{ij} = \frac{E[V_j(N)]}{N},
where V_j(N) is the number of visits to j at times
1, \dots, N (the initial state, at time 0, is not counted). The
values sum to one, and multiplied by N they give the expected
numbers of visits. As N grows they converge to the stationary
distribution for an irreducible chain.
Despite the name of the function, and the title of earlier versions of this
page, the result is not the joint distribution of the numbers of visits
(V_1(N), \dots, V_n(N)), which the package does not compute (see
issue #139).
a named numeric vector with one element per state, summing to one.
Vandit Jain
transMatr<-matrix(c(0.4,0.6,.3,.7),nrow=2,byrow=TRUE)
simpleMc<-new("markovchain", states=c("a","b"),
transitionMatrix=transMatr,
name="simpleMc")
noofVisitsDist(simpleMc,5,"a")
# expected numbers of visits during the first 5 steps
5 * noofVisitsDist(simpleMc,5,"a")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.