The update defines a time-homogeneous Markov process: given its present value, the next value depends only on independent fresh input. Part (b)(i) identifies an invariant law: initializing with the rate-one exponential distribution preserves that distribution at every time. Part (b)(iii) shows convergence of the one-time laws to this invariant law from every deterministic initial value.
For a countable state space, the analogous countable-state Markov chain convergence theorem says that an irreducible Markov chain that is aperiodic and positive recurrent converges to its unique stationary distribution from every initial state. Here the state space is continuous, so that countable-state theorem does not directly supply the proof; the explicit coupling does. The two conclusions have the same equilibrium interpretation.
The difference process is a Markov chain. If the columns are equal, the next block creates a height difference of one. If the difference is , landing in the taller column increases it to , while landing in the shorter column makes it zero. Therefore its only nonzero transition probabilities areThese probabilities depend only on the present difference, not on the absolute heights or their history. This is the reset-or-increment Markov chain with .
For its stationary distribution, the incoming-flow equations give and for . Normalization uses a geometric series:ThusThe remaining balance equation is also satisfied: the flow into zero is . Every state can reach zero and every positive state can be reached from zero, so it is an irreducible Markov chain. Its invariant probability distribution makes it positive recurrent, and that distribution is unique.
The maximum-height process is not Markov. Starting empty, condition first on the positive-probability history . After two blocks the columns were equal, so after three their difference is one. Hence .
For the history , the first two blocks built one column and the third caught the other column up, leaving equal heights. Hence . Both histories have the same time and present height , but different predictions. This violates the Markov property and illustrates why a function of a Markov chain need not be Markov.
Suppose a stationary distribution exists. Its stationarity equations areSince , its masses tend to zero as , and a positive maximum is attained. Both terms on the right are at most . Since and , equality forces . Applying the same argument repeatedly at givesThese are infinitely many distinct states, contradicting . ThusThis maximum principle proof uses neither a finite expected value of the state nor the coprimality assumption.
First identify the recurrence type, rather than infer an occupation limit from a one-time probability. At time , return to zero requires exactly upward steps. The binomial distribution giveswhere the last step is Stirling's approximation. At all other positive times the return probability is zero. Hence . The recurrence criterion by return probabilities proves the recurrent property; by the irreducible Markov chain property established in (i), every state is recurrent. The equivalence of positive recurrence and existence of a stationary distribution for an irreducible Markov chain on a countable state space, together with (iii), makes this chain null recurrent.
For completeness, the zero occupation proportion follows directly by treating returns as a renewal process. Let be successive strictly positive return-cycle lengths to zero. The Strong Markov property makes them independent and identically distributed, the recurrent property makes them finite almost surely, and the null recurrent property gives . For each positive integer , the strong law of large numbers applied to givesTake a common event of probability one for these countably many . By the monotone convergence theorem, the right side increases to infinity. Thus the number of completed return cycles by time , divided by , tends to zero. Counting the initial visit changes this ratio by at most . Consequently,The walk visits zero infinitely often, but the asymptotic fraction of time spent there is zero.
The restriction is a finite Markov chain that is an irreducible Markov chain. It is aperiodic, because its upper states have self-transition probability , and the period is constant on a communicating class. We now find its stationary distribution.
Every column of sums to one. Here is the full incoming-mass check, with each total measured in units of . For , the incoming contributions are from and from the self-transition. For , they are from and from the self-transition.
For , the upward predecessor lies in exactly when , contributing units. When , that predecessor is replaced by resets from all states of , again contributing units. Independently, the downward predecessor contributes units when ; when , resets from the states of contribute those units instead. Thus every column total is units.
Therefore is a doubly stochastic matrix, and the uniform distribution on is stationary:The countable-state Markov chain convergence theorem, applied to the finite closed class , gives for every . Its hypotheses hold: is finite and irreducible, hence positive recurrent, and it is aperiodic.
If , the hitting time of has . If , the corresponding tail is . Thus almost surely from every exterior initial state. Conditioning on and , use convergence within after entrance and the bounded convergence theorem; equivalently, first restrict to and then let . This proves, for every ,The limiting distribution is independent of .
(b)(i): communicating classes. Every increment is divisible by , so the residue class modulo is preserved. Conversely, if is divisible by , Bézout's identity applied to gives a path just as in (b)(i). Thus the original Markov chain is reducible on , with exactly the closed communicating classesThe specified walk starting at zero stays in .
(b)(ii): period of a state in a Markov chain. The return equation reduces to . Hence , . For every state, the period of a state in a Markov chain is thereforeThis is still at least two, so no state is aperiodic.
(b)(iii): stationary distribution. The conclusion is unchanged: there is no stationary distribution on . The maximum-mass proof in (b)(iii) applies verbatim, without using coprimality. Equivalently, each closed communicating class, after translating and dividing its state labels by , is the same centered random walk with step sizes and has no stationary distribution.
(b)(iv): occupation of zero. On , the rescaled walk has exactly the transition probabilities of the coprime walk with parameters . The return-probability argument in (b)(iv) therefore makes this class null recurrent. The renewal process proof of the occupation limit applies unchanged:Starting in another residue class would make every visit to zero impossible, also giving occupation proportion zero.
(c)(i): modified communicating classes. These are unchanged: is one finite closed communicating class, and all other states are transient singleton classes. The original proof used consecutive reset destinations and never used coprimality. Resetting to the consecutive integers connects different residue classes, so it would be incorrect to split according to residue classes modulo .
(c)(ii): limiting distribution. The column-sum calculation, the irreducible Markov chain property on a finite class, positive self-transition probabilities, and geometric entrance argument also required no coprimality. Thus for every initial state the same convergence in distribution holds:In particular, the denominator is unchanged; it is not divided by .
For the countable-state Markov chain ergodic theorem, let the Markov chain be irreducible and positive recurrent, with its unique stationary distribution . From any initial state, for every real satisfying ,In particular, almost surely. This time-average conclusion requires no aperiodicity.
The countable-state Markov chain convergence theorem adds the hypothesis of an aperiodic Markov chain and concludesIt also follows that for every initial probability distribution . For an irreducible recurrent chain, the occupation-frequency theorem can also be stated as a limit , interpreted as zero for a null recurrent state; in the positive recurrent case this equals .
We use the stationary weights of a reflected birth-death chain, also verifying why they decide the question. If a stationary distribution exists, its equation at zero is . At , stationarity givesThus the edge flow is constant, and its value at the boundary is zero. Every stationary distribution must therefore satisfy detailed balance on each edge. Since irreducibility forces , it must be proportional toConversely, if , normalizing these positive weights gives a probability distribution satisfying detailed balance, hence a stationary distribution. Existence of a stationary distribution for an irreducible Markov chain on a countable state space is equivalent to positive recurrence.
Every step changes the population by one, so has the parity of when . Hence . A return in two steps has positive probability from every state, and all return times are even, so the period of a state in a Markov chain is exactly two.
Each transition exchanges the even and odd classes. Since is an invariant distribution, their masses are equal: . The chain sampled at times , restricted to the even states, is irreducible and positive recurrent, and it is aperiodic because its diagonal entries are positive. Its stationary distribution is on even . The countable-state Markov chain convergence theorem applied to this sampled chain yieldsSince , the full sequence has no limit. Its time average nevertheless tends to by the countable-state Markov chain ergodic theorem.
The total eventual mass of the closed class is . The other closed class cannot contribute to state five. Since , the two-state chain within the last class converges to its stationary distribution, with state-five mass . Therefore
A stationary distribution satisfies and . The first equation reduces to the balance relation . Since , normalization gives the unique solution
A stationary distribution is a probability row vector satisfying . Its coordinates obey and . ThusBecause both transitions between distinct states have positive probability, the finite Markov chain is irreducible; its positive self-transition probabilities also make it aperiodic.
The finite irreducible aperiodic Markov chain converges to its stationary distribution, regardless of its initial law. Therefore . Taking the arithmetic means of this convergent sequence givesThis uses linearity of expectation and convergence of Cesàro means; it does not require the variables to be independent.
The state-zero stationary distribution equation is , so . The state-one equation is , giving . More generally, the stationary probability flow across the cut is balanced, so . This also follows inductively from .
Hence . Since , the geometric series is summable, and normalization givesThese probabilities satisfy detailed balance and therefore all the stationarity equations. The Markov chain is an irreducible Markov chain, so this normalized stationary distribution is unique.
A finite irreducible aperiodic Markov chain converges to its unique stationary distribution from every initial state. Finiteness holds because nonnegative entries with fixed finite row sums are bounded. The given connecting-sequence property makes the chain irreducible: each feasible step in such a sequence has positive proposal probability and is accepted. The all-zero index table occurs with probability and gives a self-loop at every state, establishing aperiodicity. Reversibility supplied the stationary uniform law in (b). ConsequentlyThe conclusion also holds when the feasible state space is a singleton.
If , induction gives for all . By (c), the marginal distribution at time is consequently . Such a probability vector is a stationary distribution.
For the chain is irreducible, and the normalized stationary distribution in (i) makes it positive recurrent. The mean-return-time formula givesHere includes a return at time one when the chain stays at zero. This convention is essential. Equivalently the mean hitting time of zero from one is , so a first-step decomposition gives , the same result. For the population remains zero and the next zero is at time one, also agreeing with the formula.
Choose distinct coordinates uniformly for the starting ones; each element of then has starting probability . At each iteration choose one current one and one current zero uniformly and swap them. This implements the normalized proposal distribution from (c)(i), remains in , and needs just one precomputed matrix inverse.
mymcmc <- function(x, k, sigma) {
n <- length(x)
stopifnot(length(k) == 1L, is.finite(k), k == floor(k),
k > 0L, k < n, is.matrix(sigma),
all(dim(sigma) == c(n, n)))
sigma_inv <- invsigma(sigma)
u <- integer(n)
u[sample.int(n, k, replace = FALSE)] <- 1L
draws <- matrix(0, 100L, n)
for (iteration in seq_len(100L)) {
ones <- which(u == 1L)
zeros <- which(u == 0L)
i <- ones[sample.int(length(ones), 1L)]
j <- zeros[sample.int(length(zeros), 1L)]
v <- u
v[i] <- 0L
v[j] <- 1L
alpha <- mylogapp(x, u, v, sigma_inv)
if (runif(1L) < alpha) u <- v
draws[iteration, ] <- u
}
colMeans(draws)
}Sampling positions with
sample.int and then indexing into ones or zeros also works when or . In R, a call such as sample(ones, 1) would incorrectly sample from 1:ones when ones is a single numeric value greater than one.The code records the state after each of exactly transitions, including repetitions after rejection. Its answer is the vector Monte Carlo estimatorThis estimates the posterior mean coordinate by coordinate; because each coordinate is binary, its entries estimate the posterior probabilities of inclusion. Every stored state has coordinate sum , so the estimated means lie in and sum to .
For neighbouring states, the symmetry of the proposal and the Metropolis–Hastings acceptance probability give detailed balance:Thus the posterior distribution is a stationary distribution. Any two states in can be connected by moving the ones that occupy the wrong positions, and the multivariate normal distribution gives strictly positive target masses. The resulting Markov chain is therefore an irreducible Markov chain, and its long-run state averages estimate the posterior mean.
The requested iterations are a finite approximation, without a convergence guarantee or discarded burn-in. A randomly chosen starting subset has the prior distribution, rather than generally the posterior distribution. No aperiodicity assumption is needed for the finite-state Markov chain ergodic theorem for averages; indeed a uniform two-state target with gives a period-two alternating chain. This does not invalidate either the code or the state-average estimator.
