To be able to pip install scikit-sparse, you may need to first install libsuitesparse-dev:
sudo apt install libsuitesparse-dev
The primary goal of this library is the method Inla.log_marginal_posterior
,
which estimates the parameters of a Gaussian Markov Random Field (GMRF) from
observed data. The user supplies
- A parameterized GMRF, i.e. for parameters
$\theta$ , a mean vector$\mu(\theta)$ and a sparse precision matrix$Q(\theta)$ . This is specified as an instance ofgmrf.Model
. An unobserved state$x$ is assumed to be sampled from the multivariate normal with mean$\mu$ and covariance$Q^{-1}$ . - A prior on parameters,
$p(\theta)$ . - A measurement vector
$y$ . - A measurment model:
$p(y_i|x_i) = p(y_i|x_i, \theta)$ . Our implementation assumes this distribution is the same for all$i$ , and that it is independent of$\theta$ , but all that's technically needed is that$y_i$ is independent of$x_j$ for$j\neq i$ .
Given these inputs, we compute an estimate of the marginal posterior
Our implementation is in JAX, so the marginal posterior can be automatically
differentiated with respect to
The basic strategy is to use the following formula, which holds for any value of
The GMRF specifies
This just leaves
The constant is then be determined by using the fact that this must be a
probability distribution in
What value of
until stabilization.
This library provides the low-level methods required to run the computation
above. gmrf.Model
provides a class for parameterizing a GMRF (i.e. a
multivariate gaussian with sparse precision matrix). The sparse precision
matrices are implemented with the class sparse.SPDMatrix
, which supports
adding to the diagonal (for constructing
Linear solves and log determinant calculations are powered by sparse Cholesky
factorization (sparse.sparse_cholesky_fn
) and sparse triangular solves
(sparse.tril_solver
, sparse.triu_solver
). These methods implement the naive
algorithm for Cholesky factorization or triangular solves, taking advantage of
sparsity, but looping over non-zero entries. This library would be substantially
improved if this loop could be implemented with a jax.lax.scan
. The
fundamental challenge is that jax.lax.scan
requires each operation in the loop
operate on arrays of the same shape. Since some of the rows of the Cholesky
triangle typically have a large number of non-zero entries, the straight-forward
jax.lax.scan
approach would give up the benefits of sparsity.