Skip to content

peekxc/primate

Repository files navigation

build_macos build_windows build_linux Python versions

primate, short for Probabalistic Implicit Matrix Trace Estimator, is a Python package that provides estimators of quantities derived from matrix functions; that is, matrices parameterized by functions:

$$ f(A) \triangleq U f(\Lambda) U^{\intercal}, \quad \quad f : [a,b] \to \mathbb{R}$$

This definition is quite general in that different parameterizations of $f$ produce a variety of spectral quantities, including the numerical rank, the log-determinant, the trace inverse, the Schatten norms, the trace of matrix exponentials, the eigencount, the spectral density, etc.

Notable features of primate include:

  • Efficient methods for trace, quadrature, and matrix function approximation
  • Various distribution / engine choices for random vector generation (the stochastic part!)
  • Support for arbitrary matrix functions, i.e. Callable's (Python) and invocable's1 (C++)
  • Support for arbitrary LinearOperator's, e.g. those in SciPy or Pylops
  • Matrix-free interface to the Lanczos, Golub-Welsch, and Gram Schmidt methods

primate was partially inspired by the imate package---for a comparison of the two, see here.

Applications

Applications of matrix functions include characterizing folding in proteins, principal component regression, spectral clustering, Gaussian process likelihood estimation, counting triangles in distributed-memory networks, characterizing graph similarity, and deep neural loss landscape analysis.

Installation

primate is a standard PEP-517 package that can be installed via pip:

python -m pip install scikit-primate

Assuming your platform is supported, no compilation is needed—see the installation page for details.

Footnotes

  1. This includes std::function's, C-style function pointers, functors, and lambda expressions.