#
# InitiationFunction.R
#
# Initiation function of a Markov chain having initial distribution mu.
# See p.19 in Häggström (2002).
#
# Lasse Leskelä 2011-11-04
#
# Input:
# x  (real number in (0,1)) argument of the initiation function
# mu (k-vector) initial distribution of the Markov chain: mu(i) = Pr(X(0)=i)
#
# Output:
# i (integer in [1,k]) the initiation function evaluated at x
#

InitiationFunction <- function (x,mu) {
 k <- length(mu)
 F <- cumsum(mu)

 i <- 1
 while (i < k && x >= F[i]) {
  i <- i+1
 }
 i
}
