https://github.com/timweiland/gaussianmarkovrandomfields.jl
Bayesian inference on spatial and spatiotemporal data, faster than you can say "Cholesky!"
https://github.com/timweiland/gaussianmarkovrandomfields.jl
bayesian-inference gmrf linear-algebra spatial-statistics spde
Last synced: 10 months ago
JSON representation
Bayesian inference on spatial and spatiotemporal data, faster than you can say "Cholesky!"
- Host: GitHub
- URL: https://github.com/timweiland/gaussianmarkovrandomfields.jl
- Owner: timweiland
- License: mit
- Created: 2024-07-12T12:03:53.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-10-18T22:01:50.000Z (10 months ago)
- Last Synced: 2025-10-21T11:50:43.742Z (10 months ago)
- Topics: bayesian-inference, gmrf, linear-algebra, spatial-statistics, spde
- Language: Julia
- Homepage: https://timweiland.github.io/GaussianMarkovRandomFields.jl/
- Size: 64.6 MB
- Stars: 12
- Watchers: 1
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
GaussianMarkovRandomFields.jl
⚡ Fast, flexible and user-centered Julia package for Bayesian inference with sparse Gaussians
[](https://timweiland.github.io/GaussianMarkovRandomFields.jl/stable)
[](https://timweiland.github.io/GaussianMarkovRandomFields.jl/dev)
[](https://github.com/timweiland/GaussianMarkovRandomFields.jl/actions/workflows/CI.yml?query=branch%3Amain)
[](https://codecov.io/gh/timweiland/GaussianMarkovRandomFields.jl)
[](https://github.com/JuliaTesting/Aqua.jl)
[](https://github.com/fredrikekre/Runic.jl)
Gaussian Markov Random Fields (GMRFs) are Gaussian distributions with sparse
precision (inverse covariance) matrices.
GaussianMarkovRandomFields.jl provides utilities for working with GMRFs in Julia.
The goal is to enable **flexible** and **efficient** Bayesian inference from
GMRFs, powered by sparse linear algebra.
In particular, we support the creation of GMRFs through finite element method
discretizations of stochastic partial differential equations (SPDEs).
This unlocks efficient GMRF-based approximations to commonly used Gaussian
process priors.
Furthermore, the expressive power of SPDEs allows for flexible, problem-tailored
priors.
## Contents
- [Installation](#installation)
- [Your first GMRF](#your-first-gmrf)
- [Contributing](#contributing)
## Installation
GaussianMarkovRandomFields.jl is not yet a registered Julia package.
Until it is, you can install it from this GitHub repository.
To do so:
1. [Download Julia (>= version 1.10)](https://julialang.org/downloads/).
2. Launch the Julia REPL and type `] add https://github.com/timweiland/GaussianMarkovRandomFields.jl`.
## Your first GMRF
Let's construct a GMRF approximation to a Matérn process from observation points:
``` julia
using GaussianMarkovRandomFields
# Define observation points
points = [0.1 0.0; -0.3 0.55; 0.2 0.8; -0.1 -0.2] # N×2 matrix
# Create Matérn latent model (automatically generates mesh and discretization)
model = MaternModel(points; smoothness = 1)
x = model(range = 0.3) # Construct GMRF with specified range
```
`x` is a Gaussian distribution, and we can compute all the things Gaussians are
known for.
```julia
# Get interesting quantities
μ = mean(x)
σ_marginal = std(x)
samp = rand(x) # Sample
Q = precision_map(x) # Sparse precision matrix
# Form posterior under point observations using new helpers
using Distributions: Normal
obs_model = PointEvaluationObsModel(model.discretization, points, Normal)
y = [0.83, 0.12, 0.45, -0.21]
obs_likelihood = obs_model(y; σ = 0.1)
x_cond = gaussian_approximation(x, obs_likelihood) # Posterior GMRF!
```
Make sure to check the documentation for further examples!
## Contributing
Check our [contribution guidelines](./CONTRIBUTING.md).