Skip to main content

Computational Uncertainty Quantification for Inverse problems in Python

Project description

CUQIpy logo

Computational Uncertainty Quantification for Inverse Problems in python

pytest docs PyPI

CUQIpy stands for Computational Uncertainty Quantification for Inverse Problems in python. It's a robust Python package designed for modeling and solving inverse problems using Bayesian inference. Here's what it brings to the table:

  • A straightforward high-level interface for UQ analysis.
  • Complete control over the models and methods.
  • An array of predefined distributions, samplers, models, and test problems.
  • Easy extendability for your unique needs.

CUQIpy is part of the CUQI project supported by the Villum Foundation.

📚 Resources

🚀 Quickstart

Install CUQIpy using pip:

pip install cuqipy

For more detailed instructions, see the Getting Started guide.

🧪 Quick Example - UQ in a few lines of code

Experience the simplicity and power of CUQIpy with this Image deconvolution example. Getting started with UQ takes just a few lines of code:

# Imports
import matplotlib.pyplot as plt
from cuqi.testproblem import Deconvolution2D
from cuqi.distribution import Gaussian, LMRF, Gamma
from cuqi.problem import BayesianProblem

# Step 1: Set up forward model and data, y = Ax
A, y_data, info = Deconvolution2D(dim=256, phantom="cookie").get_components()

# Step 2: Define distributions for parameters
d = Gamma(1, 1e-4)
s = Gamma(1, 1e-4)
x = LMRF(0, lambda d: 1/d, geometry=A.domain_geometry)
y = Gaussian(A@x, lambda s: 1/s)

# Step 3: Combine into Bayesian Problem and sample posterior
BP = BayesianProblem(y, x, d, s)
BP.set_data(y=y_data)
samples = BP.sample_posterior(200)

# Step 4: Analyze results
info.exactSolution.plot(); plt.title("Sharp image (exact solution)")
y_data.plot(); plt.title("Blurred and noisy image (data)")
samples["x"].plot_mean(); plt.title("Estimated image (posterior mean)")
samples["x"].plot_std(); plt.title("Uncertainty (posterior standard deviation)")
samples["s"].plot_trace(); plt.suptitle("Noise level (posterior trace)")
samples["d"].plot_trace(); plt.suptitle("Regularization parameter (posterior trace)")

Sharp image (exact solution) Blurred and noisy image (data) Estimated image (posterior mean) Uncertainty (posterior standard deviation) Noise level (posterior trace) Regularization parameter (posterior trace)

🔌 Plugins

CUQIpy can be extended with additional functionality by installing optional plugins. We currently offer the following plugins:

  • CUQIpy-CIL A plugin for the Core Imaging Library (CIL) providing access to forward models for X-ray computed tomography.

  • CUQIpy-FEniCS: A plugin providing access to the finite element modelling tool FEniCS, which is used for solving PDE-based inverse problems.

  • CUQIpy-PyTorch: A plugin providing access to the automatic differentiation framework of PyTorch within CUQIpy. It allows gradient-based sampling methods without manually providing derivative information of distributions and forward models.

💻 Maintainers

🌟 Contributors

A big shoutout to our passionate team! Discover the talented individuals behind CUQIpy here.

🤝 Contributing

We welcome contributions to CUQIpy. Please see our contributing guidelines for more information.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cuqipy-1.2.0.post0.dev314.tar.gz (2.3 MB view details)

Uploaded Source

Built Distribution

CUQIpy-1.2.0.post0.dev314-py3-none-any.whl (2.3 MB view details)

Uploaded Python 3

File details

Details for the file cuqipy-1.2.0.post0.dev314.tar.gz.

File metadata

  • Download URL: cuqipy-1.2.0.post0.dev314.tar.gz
  • Upload date:
  • Size: 2.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for cuqipy-1.2.0.post0.dev314.tar.gz
Algorithm Hash digest
SHA256 b92fa7c874ca652c0e68e8f6beff445794f1eaf0e03113e0660786440a2d748f
MD5 3493d83d2da10ba347ddd747b29f3658
BLAKE2b-256 8c4b7426cf2377824ff6dc08c4c8a13b769d601b1de26041e9d9d7f37b5e4299

See more details on using hashes here.

File details

Details for the file CUQIpy-1.2.0.post0.dev314-py3-none-any.whl.

File metadata

File hashes

Hashes for CUQIpy-1.2.0.post0.dev314-py3-none-any.whl
Algorithm Hash digest
SHA256 24127e75906d45d39f0a02195855f905147360f9265b8032804adedb24ededf1
MD5 2217dd6a08004f05dd0a497f41b0522e
BLAKE2b-256 18f701e7f61bab1d40bcbc9e3aa17cad86330cbdf5f7ec30be1fb5d55c09803f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page