Integrating the joint probability density over the auxiliary coordinate, as in (i), gives the marginal distribution
In particular, augmenting with preserves the target probability distribution of . The other marginal distribution, though not needed to identify , is for . It need not be a uniform distribution on .
Write where , assigning zero elsewhere. The envelope ensures , and is nonnegative. Integrating its joint probability density over the auxiliary coordinate gives
Consequently . This proves normalization of a probability distribution; the change of integration order is justified by Tonelli's theorem.
The coordinates are generally dependent. For , their conditional probability density is
Thus has a uniform distribution on an interval whose endpoint depends on . They are independent exactly when is constant for -almost every , since only then do these conditional laws agree. In particular, is an exception: and are independent. An unconditional answer that they can never be independent would therefore be too strong.
The definition of and (c)(i) give . Nonnegativity of the variance strengthens the lower bound to
In fact the variance of one weighted observation is exactly
It is finite by the envelope. For , the central limit theorem gives approximate two-sided coverage , so the paper's rounded quantile yields
If , the weighted observation equals almost surely, and one draw is sufficient. These are theoretical budgets: and may themselves be unknown and need preliminary estimation in an implementation.
Compare with the average rejection sampling cost . Ignoring integer rounding, importance sampling uses fewer proposal draws at the same approximate precision precisely when
For literal integer budgets, the comparison is . The simpler strict inequality is the intended leading-order condition. The bound alone does not ensure an improvement when ; this is a proposal-budget variance comparison of importance and rejection sampling.
Draw independent and identically distributed random variables and use the importance weight . The importance sampling estimator is
The envelope supplies the support condition for importance sampling. Since , this is an unbiased estimator. Moreover, , so
Here . Subtracting the squared expected value and dividing by proves the bounded-weight importance-sampling moment bound in the requested form:
With a fixed budget of independent proposal trials, the accepted count has binomial distribution with success probability . Hence
For , the central limit theorem gives the one-sided approximation
Use , 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 budget
Equivalently, 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.
Stop rejection sampling when exactly target draws have been accepted. The total proposal count is a sum of independent waiting times with geometric distribution, equivalently a negative binomial distribution counting trials. Consequently
The accepted-sample Monte Carlo estimator then has the approximate precision from (a)(iii). The displayed proposal cost is an expected value, which need not be an integer. Spending this many proposals in advance does not ensure that target draws will have been accepted.
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 gives
Taking 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 is
The proposal count up to and including one acceptance has the geometric distribution
For example, the tail-sum formula gives . Thus the expected cost is proposal draws per accepted target draw.
The central limit theorem gives , so, with the cumulative distribution function of the standard normal distribution,
The error has two tails. Using the supplied quantile, whose two-sided coverage is approximately , gives
The supplied quantile would be appropriate for a one-sided calculation; it would give only approximately two-sided coverage. Using the exact quantile instead of would give draws; we consistently use the paper's rounded value below.
For routine Monte Carlo integration, the central limit theorem calculation is preferable as a practical budget: it uses about one fifteenth as many draws as the Chebyshev's inequality bound. However, its coverage is approximate. Finite variance alone supplies no universal rate of convergence to the normal distribution; an integrand with large skewness or a heavy-tailed distribution can make the approximation poor even at a large sample count. If an unconditional finite-sample guarantee is required under only the stated assumptions, use the Chebyshev's inequality budget.
Apply Chebyshev's inequality to the Monte Carlo estimator:
Thus suffices, giving
This 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.
Generate independent and identically distributed random variables with probability density function , evaluate for each draw, and return the Monte Carlo estimator
Linearity of expectation makes this an unbiased estimator: . Independence and the specified variance give . Its Monte Carlo standard error is therefore , and the strong law of large numbers gives convergence to almost surely.
Use several complementary Markov chain Monte Carlo convergence diagnostics, monitoring both and rather than judging the chain solely by its length:
A million iterations and stable-looking plots do not prove convergence. Agreement across dispersed chains, exploration of all visible modes and adequate effective sample size of a Markov chain provide stronger evidence. Estimate the Monte Carlo standard error using the chain's autocorrelation; the independent random variables formula from 3(b)(ii) does not apply directly to these dependent draws.
Assume and a current state with , . The unnormalized posterior density is
Thus the log-posterior, up to an additive constant, is the log-likelihood plus the beta distribution and exponential distribution log prior densities. The exponential distribution rate is , since is its mean. [ref] [ref]
Choose a symmetric joint random-walk Metropolis algorithm proposal: and , for independent standard normal distribution draws. Its scale depends only on fixed hyperparameters, so forward and reverse proposal probability density functions agree. Reject immediately outside ; otherwise accept with Metropolis–Hastings acceptance probability
The following function makes exactly one proposal, with rejection retaining both old parameters:
MHstep <- function(x, p, beta, a, b, mu) {
  p_new <- rnorm(1, mean = p, sd = 0.1)
  beta_new <- rnorm(1, mean = beta, sd = mu / 2)
  if (p_new <= 0 || p_new >= 1 || beta_new <= 0)
    return(list(p = p, theta = beta))
  logpost <- function(pp, bb) {
    ll_f(pp, bb, x) + dbeta(pp, a, b, log = TRUE) +
      dexp(bb, rate = 1 / mu, log = TRUE)
  }
  logA <- logpost(p_new, beta_new) - logpost(p, beta)
  if (log(runif(1)) <= min(0, logA)) {
    p <- p_new
    beta <- beta_new
  }
  list(p = p, theta = beta)
}
The returned field theta contains the updated value of beta. The original PDF really asks for p and theta, although no parameter is defined in this question. This choice preserves its literal interface while making the intended second parameter explicit. A caller therefore advances with state <- MHstep(x, p, beta, a, b, mu), p <- state$p, and beta <- state$theta.
The proposal is an unrestricted symmetric normal distribution followed by rejection outside the support. Repeatedly drawing until a valid proposal appears would instead truncate and renormalize the proposal, requiring a proposal-density correction. The code uses immediate rejection and needs no such correction. The displayed scales are valid fixed choices; practical efficiency can be improved using a separate tuning phase.
Taking the logarithm of the normalized probability density function, then summing over the independent observations, gives the log-likelihood
Both and are parameters being inferred, so their contributions to the normalizing constant must be retained. The following R implementation validates the arguments and returns one number:
ll_f <- function(p, beta, x) {
  scalar <- function(v) {
    is.numeric(v) && !is.complex(v) && length(v) == 1L &&
      is.finite(v)
  }
  if (!scalar(p) || p <= 0 || p >= 1)
    stop("p must lie strictly between 0 and 1")
  if (!scalar(beta) || beta <= 0)
    stop("beta must be positive")
  if (!is.numeric(x) || is.complex(x) || !is.null(dim(x)) ||
      any(!is.finite(x)) || any(x <= 0))
    stop("x must be a vector of finite positive numbers")
  if (length(x) == 0L) return(0)
  t <- log1p(-p) - beta * x
  length(x) * (log(beta) - log(-log(p))) +
    sum(t - log(-expm1(t)))
}
Here and -expm1(t) computes accurately near zero. The empty-data likelihood function is one, so its log-likelihood is zero. Invalid parameter values produce errors in this evaluator; the next algorithm rejects candidates outside the parameter support before calling it.
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 moments
Thus 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 .
A numerical power series evaluation needs a stopping rule. For and integer , the absolute remainder after terms satisfies the polylogarithm series remainder bound
Indeed for , and the remaining powers sum as a geometric series. This also covers negative . The code sums terms in vectors of at most 4096 entries, checking the bound after each block; there is no loop over individual terms.
polylog <- function(a, z, tol = 1e-10, max_terms = 1000000) {
  scalar <- function(v) {
    is.numeric(v) && !is.complex(v) && length(v) == 1L &&
      is.finite(v)
  }
  if (!scalar(a) || a < 0 || a != floor(a))
    stop("a must be a nonnegative integer")
  if (!scalar(z) || abs(z) >= 1)
    stop("z must be real with abs(z) < 1")
  if (!scalar(tol) || tol <= 0 || tol >= 1)
    stop("tol must lie strictly between 0 and 1")
  if (!scalar(max_terms) || max_terms < 1 ||
      max_terms != floor(max_terms))
    stop("max_terms must be a positive integer")
  if (z == 0) return(0)
  r <- abs(z)
  N <- 0
  ans <- 0
  repeat {
    if (N >= max_terms)
      stop("requested truncation tolerance not reached")
    B <- min(4096, max_terms - N)
    k <- seq.int(N + 1, N + B)
    ans <- ans + sum(z^k * exp(-a * log(k)))
    N <- N + B
    log_bound <- (N + 1) * log(r) - a * log(N + 1) - log1p(-r)
    if (log_bound <= log(tol)) return(ans)
  }
}
This accepts every positive integer order in the question, and also order zero if is the convention adopted. The bound controls absolute truncation error; floating-point rounding is a separate source of error. Close to , convergence can be slow. If the resource limit is reached, the function reports failure instead of silently claiming the requested accuracy. Useful exact checks are and .
The following R function performs inverse transform sampling with vectorized numerical computation. It checks finite real scalar parameters, including a nonnegative integer sample count, and gives beta its requested default.
r_sample_f <- function(n, p, beta = 1) {
  scalar <- function(v) {
    is.numeric(v) && !is.complex(v) && length(v) == 1L &&
      is.finite(v)
  }
  if (!scalar(n) || n < 0 || n != floor(n))
    stop("n must be a nonnegative integer")
  if (!scalar(p) || p <= 0 || p >= 1)
    stop("p must lie strictly between 0 and 1")
  if (!scalar(beta) || beta <= 0)
    stop("beta must be positive")
  if (n == 0) return(numeric(0))
  v <- runif(n)
  (log1p(-p) - log(-expm1(v * log(p)))) / beta
}
Here is again a uniform distribution draw, so the expression is the quantile function from (ii). The function expm1(t) evaluates accurately when is small, avoiding cancellation in ; log1p(-p) evaluates . For default bounds, runif excludes both endpoints, so this implementation does not deliberately generate the infinite endpoint of the quantile function. It returns a numeric vector of length n, including an empty vector when n = 0. [ref] [ref]
Solving gives . Hence the quantile function is
For such , , making the logarithm's argument lie in and the output positive. Its endpoint limits are and . Substitution into (i)'s cumulative distribution function recovers .
Let . Since
integration from zero to gives . Letting and imposing unit total probability gives
The 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 .
Define . Given , the direct-return branch has probability , while the fallback branch distributes its remaining mass uniformly over . The law of total probability therefore gives, for integer ,
The summation includes : a failed direct-return test can still return through the discrete uniform distribution draw. There is no rejection loop and no additional normalization. Summing the displayed probability mass function over gives . At , for example, at every ; it does not become one. This is an instance of the accept-or-fallback mixture identity.
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 , so
For 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.

Pinned article: Introduction to the OurBigBook Project

Welcome to the OurBigBook Project! Our goal is to create the perfect publishing platform for STEM subjects, and get university-level students to write the best free STEM tutorials ever.
Everyone is welcome to create an account and play with the site: ourbigbook.com/go/register. We belive that students themselves can write amazing tutorials, but teachers are welcome too. You can write about anything you want, it doesn't have to be STEM or even educational. Silly test content is very welcome and you won't be penalized in any way. Just keep it legal!
We have two killer features:
  1. topics: topics group articles by different users with the same title, e.g. here is the topic for the "Fundamental Theorem of Calculus" ourbigbook.com/go/topic/fundamental-theorem-of-calculus
    Articles of different users are sorted by upvote within each article page. This feature is a bit like:
    • a Wikipedia where each user can have their own version of each article
    • a Q&A website like Stack Overflow, where multiple people can give their views on a given topic, and the best ones are sorted by upvote. Except you don't need to wait for someone to ask first, and any topic goes, no matter how narrow or broad
    This feature makes it possible for readers to find better explanations of any topic created by other writers. And it allows writers to create an explanation in a place that readers might actually find it.
    Figure 1.
    Screenshot of the "Derivative" topic page
    . View it live at: ourbigbook.com/go/topic/derivative
  2. local editing: you can store all your personal knowledge base content locally in a plaintext markup format that can be edited locally and published either:
    This way you can be sure that even if OurBigBook.com were to go down one day (which we have no plans to do as it is quite cheap to host!), your content will still be perfectly readable as a static site.
    Figure 5. . You can also edit articles on the Web editor without installing anything locally.
    Video 3.
    Edit locally and publish demo
    . Source. This shows editing OurBigBook Markup and publishing it using the Visual Studio Code extension.
  3. https://raw.githubusercontent.com/ourbigbook/ourbigbook-media/master/feature/x/hilbert-space-arrow.png
  4. Infinitely deep tables of contents:
    Figure 6.
    Dynamic article tree with infinitely deep table of contents
    .
    Descendant pages can also show up as toplevel e.g.: ourbigbook.com/cirosantilli/chordate-subclade
All our software is open source and hosted at: github.com/ourbigbook/ourbigbook
Further documentation can be found at: docs.ourbigbook.com
Feel free to reach our to us for any help or suggestions: docs.ourbigbook.com/#contact