bayespecon.logdet.logdet_mc_poly_pytensor

bayespecon.logdet.logdet_mc_poly_pytensor(rho, traces)[source]

Evaluate Barry-Pace trace polynomial approximation of log|I - rho*W| symbolically.

Computes the truncated power-series approximation

\[\log|I_n - \rho W| \approx -\sum_{k=1}^{m} \frac{\rho^k}{k}\,\hat{\tau}_k\]

where \(\hat{\tau}_k \approx \text{tr}(W^k)\) are the Barry-Pace stochastic trace estimates from compute_flow_traces(), using Horner’s method for numerically stable evaluation.

Unlike mc() (which builds a lookup table over a fixed rho grid), this function returns a symbolic pytensor expression valid for any \(\rho \in [-1, 1]\) and is therefore suitable for use inside a PyMC model as a pm.Potential.

Parameters:
rho : pytensor scalar

Spatial autoregressive parameter symbol.

traces : np.ndarray, shape (m,)

Trace estimates traces[k-1] tr(W^k) for k=1..m from compute_flow_traces().

Returns:

Symbolic polynomial approximation of the log-determinant.

Return type:

pytensor.tensor.TensorVariable

Notes

Horner evaluation of \(-\sum_{k=1}^m w_k \rho^k\) where \(w_k = \hat{\tau}_k / k\):

\[-\rho \bigl(w_1 + \rho(w_2 + \rho(\cdots + \rho\, w_m)\cdots)\bigr)\]