Since , its finite mean satisfies . Every is nonnegative, andThus is a probability mass function. It defines the size-biased distribution of : an outcome of size receives times its original relative weight.
A discrete random variable on a probability space is a real-valued measurable function whose probability distribution is concentrated on some finite or countable set :Measurability means for every real . Its probability mass function is , and . Requiring a countable image everywhere, rather than outside a null set, is an equivalent convention after harmless modification on a null set.
For each nonnegative integer , the events , , are pairwise disjoint and their union is . By countable additivity and then independence,This is the discrete convolution of the two probability mass functions. If the convention for natural numbers excludes zero, set both probability mass functions equal to zero there; the formula remains valid. Also for negative .
Normalization of the probability mass function requiresThusThe resulting law is the Poisson distribution with parameter .
Normalization of the probability mass function and the geometric series giveThe tail is another geometric series:
Assume , and work on the support . In rejection sampling, choose a normalized proposal probability mass function and a known finite constant satisfying everywhere. Draw independent random variables and , accepting when . The joint probability of proposing and accepting is , so the overall acceptance probability is and the accepted value has probability mass function . Fresh trials therefore produce independent and identically distributed random variables with the desired probability distribution. For a fixed positive number of accepted values, the sample average is an unbiased estimator of the expectation when that expectation is finite. Its variance is if the second moment is finite. Finding a valid envelope can be difficult, and a small acceptance probability makes the method expensive.
For the Metropolis–Hastings algorithm, choose a proposal transition matrix and, at the current state , propose . Accept with the Metropolis–Hastings acceptance probabilityA proposal outside is rejected; an impossible proposal need not be assigned a ratio. Otherwise remain at . This constructs a Markov chain satisfying detailed balance with , without computing or a global envelope. Estimate the expectation by averaging over iterations, including repeated states after rejections. Keeping only accepted jumps generally changes the stationary distribution of the recorded process.
The Metropolis–Hastings algorithm produces dependent samples, so the variance of its average includes autocovariances; starting outside stationarity can also cause finite-run bias. With Markov chain irreducibility, suitable recurrence and an integrable , the countable-state Markov chain ergodic theorem gives consistency. Aperiodicity is additionally needed for the usual convergence of one-time probability distributions. In contrast, accepted rejection sampling values need no initial transient. Neither method is universally faster: envelope rejection competes with the proposal quality and mixing time of the Markov chain. Nonnegativity of alone does not guarantee a finite expectation or variance.
Use the Poisson distribution with probability mass function on . A symmetric nearest-neighbour proposal with a reflecting boundary isAll other entries vanish. In particular, the boundary proposal does not force a move to one: retaining the probability makes .
The adjacent ratios of the Poisson distribution are and . The Metropolis–Hastings acceptance probability consequently giveswhere the symbol denotes the upward transition probability. Thus the complete transition matrix iswith no downward entry at zero and all other entries zero. In matrix form,Every row is nonnegative and sums to one. An executable Python step of this Poisson Metropolis chain is:
def poisson_step(n, lam, rng):
if lam <= 0 or n < 0 or int(n) != n:
raise ValueError("require lam > 0 and an integer n >= 0")
y = n + 1 if rng.random() < 0.5 else max(0, n - 1)
ratio = lam / (n + 1) if y > n else n / lam if y < n else 1.0
return y if rng.random() < min(1.0, ratio) else nSupply a pseudorandom number generator such as
random.Random(2021) and retain each returned state, including repeats. No normalizing constant or evaluation of a factorial is needed by the algorithm.The discrete base factors in the displayed construction inherit their variational parameters. Accordingly write , not a parameter-independent , for the joint base probability mass function or probability density function. The continuous noise factors can be parameter independent while the discrete factors are dependent. Calling the entire base law parameterless while retaining its nonzero score function would be inconsistent.
Let push the base law forward to , and defineUse a fixed base measure , with counting measure for discrete coordinates and Lebesgue measure for continuous coordinates. Assume locally parameter-independent support, differentiability and an integrable domination permitting differentiation under the integral sign. A valid reparameterization gradient givesApply the product rule before simplifying:This is the required combined score and pathwise gradient estimator. A sample from and the integrand on the last line give an unbiased stochastic gradient under the stated regularity conditions. Its first term is a score-function gradient estimator contribution; the remaining terms differentiate the sampled objective along the continuous transformation. The same separation appears in the general stochastic computation graph construction.[ref]
All derivatives inside the expectation hold fixed. They still include both explicit parameter dependence and dependence through . For a continuous coordinate ,The model joint density is fixed as changes, but its composition with need not be constant. Discrete coordinates are not differentiated as real-valued paths; their changing probabilities enter through the score function. Moving supports or parameter-dependent branch boundaries require additional care and are not justified merely by formally interchanging a derivative and an integral.
Subtract adjacent values of the cumulative distribution function. Its value at zero is zero, so the same calculation applies also to :The probability mass function sums to one by a telescoping series.
Write . The new random variable is independent of the entire history generated by , hence of . This is a Markov chain obtained from independent innovations: conditional on the past, only the current sum enters the next state. Its time-homogeneous transition probabilities areEvery jump is a positive integer, and each row sums to one by the probability mass function from part (b).
Using the probability mass function of the Poisson distribution and the power series of the exponential function,This moment-generating function of a Poisson distribution is finite for every real . It also covers , when with probability one and the moment-generating function is identically one.
Since almost surely, only finitely many early values can attain the global minimum; it is a finite integer. Also . For every nonnegative integer , the unit-step property and translation invariance of the increments giveSubtracting consecutive tails yields the probability mass functionThus has the geometric distribution counting failures before the first success, with success parameterThis support convention is essential: the minimum of an upward-biased random walk can equal its starting position, so has positive probability.
Write . The target Poisson distribution and proposal geometric distribution have probability mass functions and . Their ratio isThe successive ratio shows that a maximizing integer is , with a tie at when is an integer. Thus the tight envelope isFor any fixed , draw using (ii)'s inversion formula with this new parameter, and draw an independent from the uniform distribution on . Accept whenotherwise restart. The acceptance probability is and the expected number of proposals is .
To minimize that expected count, set . The exact answer isHere is a proof that includes the changes of maximizing integer. Each is a convex function of , since its second derivative is . Their pointwise maximum is also a convex function. When is fixed its derivative isIf , take , where changes from on the left to on the right. The left derivative is nonpositive because ; the right derivative is nonnegative because . This is a minimum. If , take . There and the active branch has except for the endpoint tie; its derivative vanishes. Convexity again proves the global minimum. The formulas agree at the boundary.
For a fully specified optimal algorithm, compute and once, then use the preceding acceptance test with and . At an integer tie either maximizing integer gives the same test. In code, factorials can be evaluated through the logarithm of the gamma function:and acceptance is . This avoids overflowing factorials.
The optimum minimizes expected trials, the usual idealization of time when each proposal and test has constant cost. Actual runtime also depends on the implementation of discrete inversion and factorial evaluation. Simply minimizing an upper bound for would not necessarily give the exact optimum above; see optimal geometric envelope for a Poisson distribution.
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.
For a scalar statistical parameter in a regular model with probability mass function , define the one-observation expected Fisher information byThe Jeffreys prior is the prior density specified, up to a factor independent of , byFor independent observations the Fisher information is , so the factor does not change this prior distribution. If is finite, divide by this integral to normalize; otherwise the rule defines an improper prior.
Conditioning on the observed time. The native PDF defines as the first production time and then conditions on that production occurring at . If the intended information is its numerical value , the answer depends on . We first compute this conditional probability using a conditional probability density; conditioning on an exact value of a continuous random variable means a density ratio, since .
Before , no molecules of the second chemical species are present, so the joint-removal chemical reaction cannot occur. Molecules of the first chemical species arrive as a rate- Poisson process, and each independently starts a clock with a rate- exponential distribution for producing the first molecule of the second chemical species. Define the unnormalized probability mass functionThe chemical master equation before the first production, with production treated as killing, isMultiplying by and summing gives a partial differential equation for the probability generating function:Its solution, verifiable by direct differentiation, isThus , the survival function is , and the conditional distribution of given survival to is a Poisson distribution of mean .
Production in from Markov chain state has joint probability . Therefore the probability density function of isThe first production leaves unchanged. Taking the density ratio gives a size-biased distribution of the surviving count:In particular, under this reading the requested conditional probability isThe shift by one matters: an observation made exactly when production occurs preferentially selects larger counts, since their production reaction propensity function is larger.
Without observing the numerical time. If the conditioning merely repeats the definition of , the requested probability is instead the unconditional count at that stopping time. Before production, increases by one at rate , while production occurs at rate in Markov chain state . The competing exponential clocks implyThe first factor requires a second arrival before production from count one; the second requires production before a third arrival. The first arrival itself is certain. Production eventually occurs with probability one, as is also clear from . As a consistency check, averaging the time-conditioned answer against givesThese are two distinct, explicitly specified interpretations of the printed conditioning.
Count the ordered roll pairs producing each value. The probability mass functions areand are zero outside these ranges. Both counts have a unique peak:However, forces equal rolls, whose sum is even. Hence , whereas the product of the two marginal probabilities is . This disproves independence of random variables:
For each random variable, the probability mass function givesLet . By linearity of expectation and variance additivity for independent random variables,The independence is needed for the variance calculation, but not for the mean.
Using the probability mass function of the Poisson distribution directly givesFor each fixed positive integer , this series converges: the ratio of successive nonzero terms is , which tends to zero. Equivalently, using the polynomial identity in (ii) and the factorial moments from (a)(iv) gives ; the extension of that identity to is justified in (iv).
For The first is a discrete uniform distribution; the second is a Bernoulli distribution on Boolean values. Their exact mathematical probability mass functions areEach support contains exactly the positive-probability outcomes once, and the probabilities sum to one.
Uniform, require a nonempty integer interval. Compute its size in Long before converting to Double, avoiding integer overflow in u-l+1. For Flip, require , and omit zero-probability outcomes from the reported support.class Uniform(l: Int, u: Int) extends FiniteDist[Int] {
require(l <= u)
private val size = u.toLong - l.toLong + 1L
def getDom: List[Int] = {
val result = List.newBuilder[Int]
var x = l.toLong
while (x <= u.toLong) { result += x.toInt; x += 1L }
result.result()
}
def getProb(x: Int): Double =
if (l <= x && x <= u) 1.0 / size.toDouble else 0.0
}
class Flip(p: Double) extends FiniteDist[Boolean] {
require(0.0 <= p && p <= 1.0)
def getDom: List[Boolean] =
if (p == 0.0) List(false)
else if (p == 1.0) List(true)
else List(true, false)
def getProb(x: Boolean): Double = if (x) p else 1.0-p
}Double approximates these exact values by floating-point arithmetic. Materializing a huge support is limited by available memory; the Long calculation keeps its cardinality and endpoints arithmetically correct.