Independence¶
- class telescopic.kernels.Independence(proposal=None)¶
Independence Metropolis-Hastings.
A proposal \(x' \sim q\) is accepted when \(\log u < [\log\pi(x') - \log q(x')] - [\log\pi(x) - \log q(x)]\). The weight \(\pi/q\) is 0 wherever \(\pi\) is 0, even where \(q\) is 0 too, so a chain at zero density accepts any proposal of finite density, as random-walk Metropolis does. A proposal where \(q\) is 0 is rejected, even where \(\pi\) is not:
sampledrew a point thatlog_densitygives no mass, such as a draw clipped onto the edge of an open support. The coupled step shares the proposal and \(u\) between the chains, which is a maximal kernel coupling (O’Leary, Wang & Jacob 2021): a pair meets when both chains accept. It is aMetropolisHastingswith anIndependenceProposalandShared.- Parameters:
- proposalobject, optional
Any object with
sample(draws)andlog_density(x), the normalized density of whatsampledraws, positive whereversamplecan land. A NaN or+inflog-density raisesValueErrorwith the point. Itsmean, if it has one that is not a method, fixes the dimension.Noneleaves the kernel untuned:tune()fits a Student-\(t_5\) located at the mean of adaptive Metropolis pilot chains, with their covariance as its scale matrix. Its report gives the largest weight \(\pi/q\) of the pilot’s draws relative to their median.
Notes
A step and a coupled step use what the proposal’s
sampleuses (d + dfnormals forMultivariateT,dwithdf=None) and 1 uniform. Each evaluates the proposal’slog_densityonce, at the proposals and at the chains whose cached value of \(\log q\) is missing or was computed at another point (IndependenceProposal):nrows when the kernel alone moves the chains.The proposal must be positive wherever the target is. The kernel never moves a chain to where \(q\) is 0, so, used alone, a proposal that misses part of the target’s support never reaches that part, and the estimates are biased from any start, without a warning. A chain at a point where the target is positive and the proposal is 0 rejects every proposal.
Meeting times are geometric only when the weights \(\pi/q\) are bounded; a proposal with lighter tails than the target gives heavy-tailed meeting times. A run then usually gives too little mass to the region where \(\pi/q\) is large, with error bars that are too small and often without a warning.
A tuned proposal covers only the modes that the pilot chains reached. On a target with well-separated modes, the chains can settle in one mode, and pairs then meet quickly in it: the estimates can be confidently wrong, and the pilot’s agreeing chains raise no warning. Give
proposalexplicitly to cover modes that are known.Examples
A proposal given explicitly, here a Student-\(t\) whose scale matrix is twice the target’s covariance, leaves nothing to tune, so the run has no tuning report:
>>> from telescopic import examples, kernels, sample >>> example = examples.gaussian(2) >>> proposal = kernels.MultivariateT(example.mean, 2 * example.cov) >>> kernel = kernels.Independence(proposal) >>> result = sample( ... example.log_prob, example.initial, kernel=kernel, ... n_replicates=50, vectorize=True, rng=0, ... ) >>> result.tuning is None True