max_transitions_pmf: Probability mass function for the maximum number of...

View source: R/max_transitions_pmf.R

max_transitions_pmfR Documentation

Probability mass function for the maximum number of transitions.

Description

Computes the p.m.f. of the maximum possible number of state transitions (Delta_m) in a two-state Markov chain conditioning on X_0 = 0 or X_0 = 1.

Usage

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

Arguments

x

maximum number of state transitions in n iterations.

n

number of Markov chain iterations.

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(Delta_m = x)

See Also

occupation_time_pmf, recurrence_time_pmf

Examples

M <- 100
deltas.0 <- get_maxK(Sx = 0:(M-1), M = M, X0 = "0")[1:M]
deltas.1 <- get_maxK(Sx = 1:M, M = M, X0 = "1")[1:M]
probs.X0 <- max_transitions_pmf(x = deltas.0, n = M,
 alpha = .02, beta = .2, X0 = "0")
probs.X1 <- max_transitions_pmf(x = deltas.1, n = M,
 alpha = .02, beta = .2, X0 = "1")
sum(probs.X0); sum(probs.X1) # should both be 1
plot(deltas.0, probs.X0, type = "h", lwd = 3,
 ylab = "Probability", xlab = expression(Delta[m]), main = "Maximum  transitions")
points(deltas.1, 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.