from primate.diagonal import diag
diag
diagonal.diag(
A,='rademacher',
pdf='tolerance',
converge=None,
seed=False,
full=None,
callback**kwargs,
)
Estimates the diagonal of a symmetric A
via the Girard-Hutchinson estimator.
This function random vectors to estimate of the diagonal of A via the approximation: \mathrm{diag}(A) = \sum_{i=1}^n e_i^T A e_i \approx n^{-1}\sum_{i=1}^n v^T A v When v are isotropic, this approximation forms an unbiased estimator of the diagonal of A.
Note
Convergence behavior is controlled by the estimator
parameter: “confidence” uses the central limit theorem to generate confidence intervals on the fly, which may be used in conjunction with atol
and rtol
to upper-bound the error of the approximation.
Parameters
Name | Type | Description | Default |
---|---|---|---|
A | Union[sp.sparse.linalg.LinearOperator, np.ndarray] | real symmetric matrix or linear operator. | required |
Union[str, Callable] | Choice of zero-centered distribution to sample random vectors from. | 'rademacher' |
|
converge | Union[str, ConvergenceCriterion] | Convergence criterion to use for convergence testing. See details. | 'tolerance' |
seed | Union[int, np.random.Generator, None] | Seed to initialize the rng entropy source. Set seed > -1 for reproducibility. |
None |
full | bool | Whether to return additional information about the computation. | False |
callback | Optional[Callable] | Callable to execute between each iteration. | None |
Returns
Name | Type | Description |
---|---|---|
Union[float, tuple] | Estimate the diagonal of A. If full = True , additional information about the computation is also returned. |
See Also
- lanczos: the lanczos tridiagonalization algorithm.
- ConfidenceCriterion: Standard estimator of the mean from iid samples.
Reference
- Ubaru, S., Chen, J., & Saad, Y. (2017). Fast estimation of tr(f(A)) via stochastic Lanczos quadrature. SIAM Journal on Matrix Analysis and Applications, 38(4), 1075-1099.
- Hutchinson, Michael F. “A stochastic estimator of the trace of the influence matrix for Laplacian smoothing splines.” Communications in Statistics-Simulation and Computation 18.3 (1989): 1059-1076.