telescopic.estimators

Estimator weights and the estimators derived from signed measures.

telescopic.estimators.averaging_times(k, m, thin)

The averaging set \(S = \{k, k + s, k + 2s, \dots\} \cap [k, m]\) for thin = s.

Parameters:
k, mint

First and last times that may be averaged, \(0 \le k \le m\).

thinint

The spacing \(s \ge 1\).

Returns:
ndarray of int, shape (len(S),)

The times of \(S\) in increasing order.

telescopic.estimators.correction_coefficients(t, k, m, lag, thin)

Coefficients \(c_t\) of the differences in the thinned estimator \(H_S\).

\[c_t = |S|^{-1}\,\#\{l \in S : l \le t - L,\ L \mid (t - l)\}\]

with \(S\) from averaging_times(). For thin = 1 it is \(v_t/(m-k+1)\) with the lag weights \(v_t\) (The time-averaged estimator, in Theory). The count is computed in constant time per \(t\): \(l = k + js\) satisfies the congruence \(js \equiv t - k \pmod L\), whose solutions form one residue class modulo \(L/\gcd(s, L)\) when \(\gcd(s, L)\) divides \(t - k\), and none otherwise.

Parameters:
tarray_like of int

Times of the differences \(h(X_t) - h(Y_{t-L})\).

k, mint

First and last averaged times, \(0 \le k \le m\).

lagint

The lag \(L \ge 1\).

thinint

The spacing \(s \ge 1\) of the averaging set.

Returns:
ndarray of float, same shape as t
telescopic.estimators.unbiased_covariance(first, second)

Unbiased estimate of \(\mathrm{Cov}_\pi(h)\) from \(R \ge 2\) replicates.

\[\widehat{\mathrm{Cov}}_\pi(h) = \bar b - \bar a\bar a^\top + S_a/R\]

with \(a_r = \hat\pi_r(h)\), \(\bar b\) the mean of \(\hat\pi_r(hh^\top)\) and \(S_a\) the sample covariance of the \(a_r\). The last two terms are minus the U-statistic \(\sum_{r \ne s} a_r a_s^\top / (R(R-1))\), which is unbiased for \(\pi(h)\pi(h)^\top\); the plug-in \(\bar a\bar a^\top\) is biased by \(\mathrm{Cov}(\bar a)\).

Parameters:
firstndarray, shape (R, p)

The values \(a_r\).

secondndarray, shape (p, p)

The mean \(\bar b\) over replicates of \(\hat\pi_r(hh^\top)\), which pools all atoms: \(R^{-1}\sum_i \omega_i h(x_i)h(x_i)^\top\).

Returns:
ndarray, shape (p, p)
telescopic.estimators.unbiased_variance(first, second)

Unbiased estimates of the variances of \(h\).

The diagonal of unbiased_covariance(), without the off-diagonal cost: \(\bar b_j - \bar a_j^2 + S_{a,jj}/R\).

Parameters:
firstndarray, shape (R, p)

The values \(a_r = \hat\pi_r(h)\).

secondndarray, shape (p,)

The mean over replicates of \(\hat\pi_r(h^2)\).

Returns:
ndarray, shape (p,)
telescopic.estimators.weighted_quantile(values, weights, q)

Quantiles of a signed measure on the line.

Equal values are merged, the cumulative weights are projected onto non-decreasing sequences by isotonic regression and clipped to [0, 1], and the quantile at level \(\beta\) is the smallest value whose projected cumulative weight is at least \(\beta\); at a level that a cumulative weight equals exactly, rounding of the sums decides between two neighboring values. For non-negative weights this is the inverted-CDF quantile. The result is consistent as the number of replicates grows, not unbiased (Jacob, O’Leary & Atchadé 2020, Proposition 3.2).

Parameters:
valuesndarray, shape (N,)

Finite values.

weightsndarray, shape (N,)

Finite signed weights, summing to 1.

qarray_like of float in [0, 1]

The levels of the quantiles.

Returns:
ndarray, shape of q