Because , the conditional acceptance probability is , even when the printed threshold exceeds one. Repeating rejected trials gives the clipped acceptance reweighting identity:For , , including . The denominator is , soFor every proposal is accepted, so reweighting by would be incorrect. At both formulas agree. Termination has probability one since the acceptance probability is in the first case and one in the second.
Let . Sinceintegration from zero to gives . Letting and imposing unit total probability givesThe probability density function is positive for because . Consequently the cumulative distribution function is increasing, starts at zero and tends to one. This verifies that the derived normalizing constant defines a probability distribution. The family is the exponential-logarithmic distribution with the complementary mixing parameter .
Let and , evaluated from the given polylogarithm formulas. Generate a large sample of independent and identically distributed random variables with
r_sample_f, and compute its sample mean and sample variance using mean and var. The central limit theorem gives the first standardized check:For the second check, the correct asymptotic variance of the sample variance involves the fourth central moment :The denominator is not unless the probability distribution has the requisite fourth central moment, as does the normal distribution. Here the probability density function decays exponentially, so all required moments are finite.To compute , expand the denominator of the probability density function as a geometric series and integrate each nonnegative term. The gamma function integral gives the raw momentsThus and . The following R code implements both checks for chosen interior parameters and large
n:p <- 0.4
beta <- 1.3
n <- 100000
raw_m <- vapply(1:4, function(j) {
-factorial(j) * polylog(j + 1, 1 - p) / (beta^j * log(p))
}, numeric(1))
m <- raw_m[1]
v <- raw_m[2] - m^2
mu4 <- raw_m[4] - 4 * m * raw_m[3] +
6 * m^2 * raw_m[2] - 3 * m^4
x <- r_sample_f(n, p, beta)
c(mean_check = sqrt(n) * (mean(x) - m) / sqrt(v),
variance_check = sqrt(n) * (var(x) - v) / sqrt(mu4 - v^2))For each check separately, an absolute value below is consistent with its approximate confidence interval. Repeat with many independent samples: the two standardized statistics should each resemble a standard normal distribution, with about outside that range. Also vary , and
n; a systematic discrepancy that grows with suggests a bias. The two checks from the same sample are generally dependent, so passing both is not itself a joint statement, nor can a finite test prove that a generator is correct.The second central limit theorem follows from the central limit theorem for the sample variance: differs by a quantity tending to zero in probability from .
Apply Chebyshev's inequality to the Monte Carlo estimator:Thus suffices, givingThis is a finite-sample probability guarantee for every target satisfying the given variance assumption. It is a sufficient sample count supplied by the inequality, rather than a claim that every such target actually needs a million draws.
With a fixed budget of independent proposal trials, the accepted count has binomial distribution with success probability . HenceFor , the central limit theorem gives the one-sided approximationUse , since now only the lower tail of the accepted count matters. Requiring and solving the resulting quadratic equation in gives the one-sided normal approximation for a rejection proposal budgetEquivalently, before rounding, this is . For the value in (a)(iii),When , every proposal is accepted and exactly. Otherwise the positive safety margin above allows for random fluctuations in the number accepted. The average cost in (b)(ii) describes stopping at the th acceptance; this answer chooses a deterministic budget that reaches that acceptance with approximately probability.
The approximation requires a sufficiently accurate normal distribution approximation to the binomial distribution. An exact budget can instead be found from its tail probabilities. Also, a chance of enough accepted draws and approximate precision conditional on obtaining them are separate claims: their intersection is not automatically a event.
Integrating the envelope shows . One trial of rejection sampling draws and an independent from the uniform distribution on , and accepts if . Repeat with fresh independent random variables after each rejection. Ratios need only be evaluated where ; the envelope makes the target zero wherever .
For any measurable set , integration of the conditional probability of acceptance givesTaking the whole domain gives acceptance probability , and dividing gives . Fresh trials therefore supply independent and identically distributed random variables with target probability density function . The corresponding Monte Carlo estimator isThe proposal count up to and including one acceptance has the geometric distributionFor example, the tail-sum formula gives . Thus the expected cost is proposal draws per accepted target draw.
Use the same acceptance indicator functions and set , . The rejection sampling estimator based on these proposals is the mean over the accepted observations:For , any fixed convention, such as zero, is harmless asymptotically. The are independent and identically distributed random variables with Bernoulli distribution and success probability , so the strong law of large numbers gives almost surely. In particular eventually almost surely. The exact identitythen holds whenever . Wherever , it follows thatA qualification is missing from the printed claim: the quotient must be defined eventually. A convenient sufficient assumption is and . Indeed, another application of the strong law of large numbers gives , ensuring that is eventually nonzero. This proves the stated quotient limit under that assumption.
As printed, the assertion is false as a universally defined quotient. For example, makes both estimates zero for every . Even excluding that example is insufficient: take to be the uniform distribution on , , and for and otherwise. Then is a simple symmetric random walk, which returns to zero infinitely often almost surely, leaving the quotient undefined infinitely often.
With integrability but no assumption , the exact multiplicative identity remains valid, and both estimates converge to almost surely. In particular almost surely. One may alternatively define the quotient's removable cases as ; that explicitly extended quantity always converges to one. These are valid repairs of the source's unrestricted statement.
For a measurable set , (i) gives the joint acceptance probabilityDivide by from (ii). The resulting conditional probability isThus every accepted value has target probability density function . Repeating rejected trials with fresh independent random variables does not change this law: the contribution from acceptance on trial is multiplied by , and summing that geometric series gives the same conditional law. Independent repetitions produce independent target draws.
Average the conditional probability in (i) over :This is exactly the acceptance mass for an unnormalized rejection envelope. In normalized form the envelope is , giving the same acceptance probability. Here bounds the ratio of the unnormalized functions, so its value need not equal the envelope constant for the normalized probability density functions.
The squeeze changes the number of expensive target evaluations, while preserving the per-proposal acceptance probability. The expected number of proposals per accepted draw is .
Fix a proposal with , and abbreviate , and . The envelope says . Assuming fresh independent uniform distribution draws at both stages, the law of total probability givesThe second term includes both reaching the residual test and passing it. If , the envelope forces and the first test accepts with probability one; the second-stage ratio is never evaluated. This is squeeze rejection sampling.
The proposal's normalization of a probability distribution isThis is the Laplace distribution with location zero and scale one. For example, generate its magnitude from the exponential distribution with rate one and give it an independent fair sign. The target is the standard normal distribution, with .
To obtain the tight envelope, let . By completing the square,Equality occurs at , so is the smallest valid envelope constant. It maximizes the acceptance probability for this fixed proposal. The supplied lower bound must be clipped at zero to satisfy the algorithm's nonnegativity requirement:This is valid because for , while is everywhere positive. Its support is .
Here is the fully specified squeeze rejection sampling procedure. Draw with probability density function , independently draw , and compute and . If , return immediately. Otherwise evaluate , independently draw , and return if . On rejection restart with fresh draws. In this example everywhere, so the residual denominator is positive.
Avoiding a target evaluation means accepting at the first test. Its unconditional probability for one proposal isFor comparison, the overall acceptance probability is . The first-stage saving is the fraction of proposals requiring no target evaluation, including both eventual accepted and rejected proposals in the denominator; it is not conditional on acceptance.
The source's function name suggests a log return value, and (c)(i) asks for , while the wording here and in (c)(iv) asks for the acceptance probability. We use the literal probability-returning convention and explicitly exponentiate the result of (c)(i):
mylogapp <- function(x, u, v, sigma_inv) {
d <- v - u
log_ratio <- as.numeric(crossprod(d, sigma_inv %*% (x - (u + v) / 2)))
log_alpha <- min(0, log_ratio)
exp(log_alpha)
}Thus
mylogapp returns , and (c)(iv) compares it directly with a uniform distribution draw. Taking the minimum before exponentiating prevents overflow. The arguments are assumed to be valid neighbouring states. A log-returning convention would instead return log_alpha and compare log(runif(1)) with it; the two conventions implement the same Metropolis–Hastings algorithm, provided the caller uses the matching comparison.Each state has exactly neighbours: choose one occupied coordinate and one unoccupied coordinate to swap. The normalized proposal distribution is thereforeThe swap relation is symmetric and the number of neighbours is constant, so . The discrete uniform distribution used as the prior distribution is also constant on , with mass . Both factors cancel in the Metropolis–Hastings acceptance probability.
Let and . The displayed multivariate normal distribution presupposes that the covariance matrix is a positive-definite matrix, so is a symmetric matrix. Expanding the difference of quadratic forms givesConsequentlyThe truncation at zero is essential: a log acceptance ratio can be positive, but the logarithm of an acceptance probability cannot.
For the particular proposed swap, let be the coordinate changing from zero to one and the coordinate changing from one to zero. Then , and the untruncated scalar simplifies further toOnly two rows and four entries of are needed for this evaluation. This is Metropolis sampling on fixed-cardinality subsets.
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.
In the steady state, conservation of probability requires , so is constant. The sign is positive because increasing gap reaches the incorporation boundary, whereas the deterministic drift points towards smaller gap. ThusAn integrating factor givesSubstitution makes the check particularly transparent:so . The constant offset is necessary for nonzero transport; a pure Boltzmann distribution would have and could not describe a steady succession of addition events. The limit is taken after applying the boundary conditions, avoiding the apparent singularity of the displayed parametrization.
In this polymerization Brownian ratchet model, a gap of width immediately accommodates one monomer. That event advances the tip by and resets the gap to zero. The threshold is therefore an absorbing boundary condition for a diffusion,All waiting-time probability lies within , so the steady occupation probability density satisfiesThere is a reinjection flux at equal to the absorption flux at . The nonpenetration constraint at zero is a reflecting boundary condition for a diffusion during each individual waiting episode. For the stationary reset process it must not be confused with setting the net current to zero: the source at reset supplies . This is how a normalized steady density can coexist with a nonzero exit flux.
For a Bernoulli distribution with fixed , the mean and variance are and . The odds transformation has derivative . Applying the delta method from part (ii),More precisely, converges to a normal distribution of mean zero and variance , after defining the statistic arbitrarily on . That exceptional event has probability , so this extension does not change the limit. The unextended ratio is undefined there and has no finite exact variance if interpreted as infinite. At it is zero almost surely; at the denominator is always zero. This is the delta method for Bernoulli odds.
For , the central limit theorem givesIf is differentiable at , the delta method applies to the first-order expansionwhere the remainder notation means that its product with tends to zero in probability. HenceThe useful nondegenerate normal approximation requires . When , the first-order limit is zero and a higher-order expansion may be needed.
Put , and . The normal distribution model givesand, up to a constant independent of , its log-likelihood function isThe score function and its zero equation areFor , this quadratic equation has exactly one positive root, giving the maximum-likelihood estimatorThe numerator of the score function is positive between its negative and positive roots and negative above its positive root. Thus the likelihood function increases up to and decreases afterwards: this is its unique global maximum on . Also, at both ends. The all-zero observation vector has probability zero; on that exceptional vector and there is no attained maximum.
The second derivative and the relevant moments areTherefore the expected Fisher information isThe support of a probability distribution is the whole real line, independent of the positive statistical parameter. The law of large numbers gives and in probability, so the displayed maximum-likelihood estimator is a consistent estimator. The regular asymptotic normality of a maximum likelihood estimator now yieldsThus the requested leading asymptotic variance on the unscaled estimator's scale is . The normal mean proportional to standard deviation model provides a reusable version of this calculation.
The Neyman-Pearson lemma concerns a simple hypothesis against another simple hypothesis . For a continuous statistical sample, put for the joint probability density functions, . A randomized statistical test is a measurable , the conditional probability of rejection after observing . Its test size is and its statistical power is .
Choose and boundary randomization so thatThen is most powerful among all tests of size at most . Thus one rejects for sufficiently large alternative-to-null likelihood ratio. If the equality set has zero probability under , the test needs no randomization. Continuous observations alone do not guarantee that their likelihood ratio has a continuous probability distribution.
For the proof, let be any competing test with . At every ,Indeed, on the first factor is ; on it is ; and on equality the product is zero. Integration giveswhich proves the claimed optimality. Moreover, when , equality of statistical power forces equality of test size and forces almost everywhere where : otherwise the nonnegative integrand would have positive integral. This proves the usual necessity assertion as well, up to equality sets and sets of zero probability under both hypotheses.