Read meeting times and the distance to stationarity¶
The meeting times of the pairs bound the distance of the chains from the target and set the cost of a run. Meeting times and distance to stationarity explains the bound. The examples use the run of Estimate anything from a result:
import telescopic
from telescopic import examples
gaussian = examples.gaussian(2)
result = telescopic.sample(
gaussian.log_prob, gaussian.initial, 1000, vectorize=True, rng=11
)
Meeting times¶
result.meeting_times holds each pair’s meeting time \(\tau\)
(Theory), inf for a pair censored at max_iter
(censored); result.costs holds its kernel applications
and result.index its replicate index.
telescopic.Result.plot_meeting_times() draws a histogram of \(\tau - L\) and its
survival function on a log scale, where a straight tail means geometric meeting times. A
censored pair counts in the survival function at every time up to its cap, where the
curve ends at the fraction of pairs censored, and not in the histogram.
result.plot_meeting_times();
The meeting times of the run, less the lag: their histogram (left) and their survival function \(P(\tau - L > t)\) on a log scale (right).¶
telescopic.plotting.survival() draws the survival function alone, from an array of
meeting times and their lag, such as the times that
telescopic.CoupledSampler.meeting_times() returns, into a given axis, so that the
curves of several runs share one; censored pairs, inf, need their cap as max_iter:
from telescopic import plotting
plotting.survival(result.meeting_times, result.lag, max_iter=result.max_iter);
The survival function \(P(\tau - L > t)\) of the run’s meeting times, drawn from the array.¶
Distance to stationarity¶
With keep, the 1-Wasserstein bound comes from the distances of the kept replicates,
censored ones included, which are the only ones stored; the meeting times, the TV bound
and the other diagnostics of this page come from every replicate.
telescopic.Result.tv_bound() estimates the upper bound on the total variation
distance between the law of \(X_t\) and the target
(Theory) by its average over the replicates,
capped at 1, and returns it with its standard error: the sample standard deviation of
the replicates’ terms \(\max(0, \lceil(\tau - L - t)/L\rceil)\) over \(\sqrt R\), the error of
the average before the cap. By default it returns both at every \(t\) from 0 to the last
time at which the bound is positive, so that entry t is the bound at t. A censored pair is known to
meet after its cap, where its chains were last compared, and counts as meeting at the
cap plus 1, so with censored pairs the estimate is a lower bound of the one without a
cap.
bound, standard_error = result.tv_bound([0, result.k // 2, result.k])
print(bound, standard_error)
[1. 0.191 0.013] [0.00358383 0.01251702 0.00358383]
telescopic.Result.plot_tv_bound() draws it on a log scale, with a band of two
standard errors and k marked:
result.plot_tv_bound();
The estimated upper bound on the total variation distance between the law of \(X_t\) and the target, against \(t\), with a band of two standard errors and \(k\) dashed.¶
telescopic.Result.w1_bound() estimates the bound on the 1-Wasserstein distance in
the same way, with its standard error, from the distances \(\lVert X_t - Y_{t-L} \rVert\)
that the engine records before each pair meets. A censored pair’s distances stop at its cap, so with censored
pairs it too is a lower bound. It depends on the parameterization of the target through
the Euclidean norm: in other units or coordinates the bound changes.
bound, standard_error = result.w1_bound([0, result.k // 2, result.k])
print(bound, standard_error)
[2.81851567 0.51518758 0.0349403 ] [0.04944883 0.04219928 0.01288599]
telescopic.diagnostics.tv_bound() and telescopic.diagnostics.w1_bound()
compute the same bounds and standard errors from arrays, such as meeting times of your
own, with each censored pair given as the cap plus 1.