occupation_time_pmf: Probability mass function for the occupation time.

View source: R/occupation_time_pmf.R

occupation_time_pmfR Documentation

Probability mass function for the occupation time.

Description

Computes the pmf for the occupation time (sum of '1's), S, in a two-state Markov chain conditioning on X_0 = 0 or X_0 = 1. This is the expression given Equation (1) of Bhattacharya & Gupta (1980), with a minor typo correction.

Usage

occupation_time_pmf(x, n, alpha, beta, X0 = c("0", "1"), log = FALSE)

Arguments

x

the number of '1's in n iterations; non-negative integer smaller than or equal to n.

n

the number of iterations in Markov chain.

alpha

a transition probability (between 0 and 1).

beta

a transition probability (between 0 and 1).

X0

initial state, either X0 == "0" or X0 == "1".

log

logical if TRUE, probabilities p are given as log(p).

Value

(log) p, where p = Pr(S = x).

References

Bhattacharya, S. K., & Gupta, A. K. (1980). Occupation times for two-state Markov chains. Discrete Applied Mathematics, 2(3), 249-250.

See Also

recurrence_time_pmf, max_transitions_pmf

Examples

M <- 100 # number of Markov chain iterations
probs.X0 <- occupation_time_pmf(x = 0:M, n = M, alpha = .02, beta = .2, X0 = "0")
probs.X1 <- occupation_time_pmf(x = 0:M, n = M, alpha = .02, beta = .2, X0 = "1")
sum(probs.X0) # should both be 1
sum(probs.X1)
plot(0:M, probs.X0, type = "h", lwd = 3, xlab = "Occupation time")
points(0:M, probs.X1, type = "h", lwd = 3, col = 2)
legend(x = "topright", col = 1:2,
   legend = c(expression(X[0]==0), expression(X[0]==1)), bty = 'n', pch = 15)


maxbiostat/BinaryMarkovChains documentation built on Dec. 11, 2023, 4:29 a.m.