telescopic.diagnostics¶
Diagnostics: bounds on the distance to stationarity, tail indices, warnings, gradient checks.
Classes
What the gradient check of a sampler built with a gradient compared. |
|
A condition that applies to a result and makes it warn. |
- telescopic.diagnostics.hill(values, n_tail)¶
Hill’s estimate of the tail index \(\alpha\) of positive values.
\[\hat\alpha = \Big[\frac{1}{k}\sum_{i=1}^{k} \log\frac{x_{(n-i+1)}}{x_{(n-k)}}\Big]^{-1}\]from the \(k\) =
n_taillargest of \(n\) values. A tail \(P(X > x) \propto x^{-\alpha}\) has finite moments below \(\alpha\) only. Where ties make the smallest value the threshold \(x_{(n-k)}\), as when most meeting times take their smallest possible value, the estimate is undefined: above such ties it reads a light tail as a heavy one. Withn_tail\(= \lfloor n/10 \rfloor\), as in thetailwarning oftelescopic.Result.check(), this happens when nine values in ten or more share the smallest.- Parameters:
- valuesarray_like, shape (n,)
Positive, finite values.
- n_tail
int The number \(k\) of upper order statistics, \(1 \le k < n\).
- Returns:
floatnanwhere ties make the smallest value the threshold, and otherwiseinfwhen the \(k + 1\) largest values are equal.
- telescopic.diagnostics.issues(result)¶
The warnings that apply to
result(Warnings, in Warnings and errors).
- telescopic.diagnostics.slow_pair_threshold(lag, m)¶
The time \(\max(10^4, 10\max(L, m))\) past which a pair is slow.
- telescopic.diagnostics.tuning_disagreement(tuning)¶
The warning about tuning chains that disagree, or
None.The chains disagree when, in some coordinate, their means spread more widely than the chains themselves: \(\hat R > \sqrt 2\), a sign of several modes or of chains that have not converged. Chains that agree do not show that the target has one mode. The warning also names the coordinates whose \(\hat R\) is NaN, where all four chains sat at one value, so the pilot never moved in them.
- Parameters:
- tuning
TuningReportorNone The report of the tuning pilot;
Nonewhen nothing was tuned.
- tuning
- Returns:
- telescopic.diagnostics.tv_bound(meeting_times, lag, t)¶
Estimated upper bound on the total variation distance to the target.
\[d_{TV}(\pi_t, \pi) \le \mathbb E\big[\max(0, \lceil (\tau - L - t)/L \rceil)\big]\](Biswas, Jacob & Vanetti 2019, Theorem 2.5), estimated by the average over replicates of \(N_r(t) = \max(0, \lceil (\tau_r - L - t)/L \rceil)\) and reported as \(\min(1, \cdot)\), with the standard error of that average.
- Parameters:
- meeting_timesarray_like of
int, shape (R,) The meeting times \(\tau\). A censored pair, given as its cap plus 1, the least meeting time it can have, makes the estimate a lower bound of the true average.
- lag
int The lag \(L\) of the runs that produced the meeting times.
- tarray_like of
int Times at which to bound the distance.
- meeting_timesarray_like of
- Returns:
- bound, standard_error
ndarray, shape oft The standard error is the sample standard deviation of the \(N_r(t)\) divided by \(\sqrt R\), of the average before it is capped at 1;
nanfor \(R = 1\).
- bound, standard_error
Notes
Computed as \(\sum_{j \ge 1} \hat S(t + jL)\) with the empirical survival function \(\hat S(u) = R^{-1}\#\{\tau > u\}\), and the second moment as \(\sum_{j \ge 1} (2j - 1)\hat S(t + jL)\), in \(O(R + \max\tau)\).
The largest share of one replicate in the sample variance of each column.
- Parameters:
- valuesarray_like, shape (R,) or (R, p)
Replicate values.
- Returns:
ndarray, shape () or (p,)0 for a column without variance, or whose values differ only by rounding.
- telescopic.diagnostics.w1_bound(distance_owner, distance_time, distance, n_replicates, lag, t)¶
Estimated upper bound on the 1-Wasserstein distance to the target.
\[d_{W_1}(\pi_t, \pi) \le \mathbb E\Big[\sum_{j=1}^{\lceil(\tau - L - t)/L\rceil} \lVert X_{t+jL} - Y_{t+(j-1)L}\rVert\Big]\](Biswas, Jacob & Vanetti 2019), estimated by the average over replicates of each replicate’s sum, with the standard error of that average. It depends on the parameterization of the target.
- Parameters:
- distance_owner, distance_time, distancearray_like, shape (M,)
The replicate, time \(s\) and distance \(\lVert X_s - Y_{s-L}\rVert\) of each record, for \(L \le s < \tau\), pooled over replicates, as
telescopic.engine.Replicatesholds them.- n_replicates
int The number of replicates \(R\), including those with no recorded distance.
- lag
int The lag \(L\) of the runs that recorded the distances.
- tarray_like of
int Times at which to bound the distance.
- Returns:
- bound, standard_error
ndarray, shape oft The standard error is the sample standard deviation of the replicates’ sums divided by \(\sqrt R\), those without a record counting as 0;
nanfor \(R = 1\).
- bound, standard_error
Notes
Costs \(O(M \log M + \max s)\).
- telescopic.diagnostics.wide_start(tuning)¶
The warning about an initial distribution far wider than the target, or
None.The tuning pilot shows a start far wider than the target when the report’s
initial_width, defined intelescopic.tuning.PilotRun.initial_width, exceeds 30. From such a start,kfrom the 99% quantile of the pilot’s meeting times can leave a few replicates still on their way to the target, and those can dominate the variance of the estimates. When the warning is emitted and listed is stated in Warnings and errors.- Parameters:
- tuning
TuningReportorNone The report of the tuning pilot;
Nonewhen nothing was tuned.
- tuning
- Returns: