bayespecon.logdet.compute_flow_traces

bayespecon.logdet.compute_flow_traces(W_sparse, miter=30, riter=50, random_state=None)[source]

Estimate tr(W^k) for k=1..miter via Barry-Pace stochastic traces.

Thin public wrapper around _barry_pace_traces(), mirroring ftrace1.m from the LeSage spatial flows toolbox. Used by _flow_logdet_poly_coeffs() to pre-compute trace products for the flow log-determinant.

Parameters:
W_sparse : array-like or scipy.sparse matrix

Row-standardised n×n spatial weights matrix.

miter : int, default=30

Number of trace orders to estimate (traces[k-1] tr(W^k) for k=1..miter). Higher values improve the polynomial approximation; 30–50 is usually sufficient with titer=800 for the geometric tail.

riter : int, default=50

Number of Monte Carlo probe vectors for trace estimation.

random_state : int, optional

Seed for reproducibility.

Returns:

Trace estimates: traces[k-1] tr(W^k) for k=1..miter.

Return type:

np.ndarray, shape (miter,)