You can multiply an matrix by vectors through a function matvec(v) (a 1-D array in, a 1-D array out) but never see itself. Implement the stochastic estimators from Murphy's book.
hutchinson_trace(matvec, n, m, dist, seed): estimate as the average of over probes. Draw all probes at once as the columns of an matrix with rng = np.random.default_rng(seed):
dist="rademacher": V = 2.0 * rng.integers(0, 2, size=(n, m)) - 1.0dist="gaussian": V = rng.standard_normal((n, m))ValueError.Call matvec once per column, in column order. Return a float.
frobenius_sq_est(matvec, n, m, seed): estimate as the average of over Gaussian probes drawn as rng.standard_normal((n, m)) from np.random.default_rng(seed). Return a float.
probe_variance(A, dist): for an explicit symmetric matrix A, return the exact variance of the single-probe estimate under the given distribution ("rademacher" or "gaussian", else ValueError), as a float.