CUQIpy plugin for FEniCS
Project description
CUQIpy-FEniCS
CUQIpy-FEniCS is a plugin for CUQIpy software package. It provides an interface between FEniCS PDE models and CUQIpy modules.
Installation
First install FEniCS (we recommend using Anaconda from the available installation options). Then install CUQIpy-FEniCS with pip:
pip install cuqipy-fenics
If CUQIpy is not installed, it will be installed automatically.
Quickstart
import numpy as np
import matplotlib.pyplot as plt
import cuqi
import cuqipy_fenics
# Load a fenics forward model and data from testproblem library
model, y_data, info = cuqipy_fenics.testproblem.FEniCSDiffusion1D.get_components(
dim=20,
endpoint=1,
exactSolution='smooth_step',
mapping='exponential',
SNR=10000,
left_bc=0,
right_bc=8
)
# Set up Bayesian model
x = cuqi.distribution.GMRF(np.zeros(model.domain_dim),
25, 1, 'zero', geometry=model.domain_geometry)
# y ~ N(model(x), 0.01^2)
y = cuqi.distribution.Gaussian(mean=model(x), cov=0.05**2)
# Set up Bayesian Problem object
BP = cuqi.problem.BayesianProblem(y, x).set_data(y=y_data)
# Sample from the posterior
samples = BP.sample_posterior(5000)
# Analyze the samples
samples.burnthin(1000).plot_ci(95, plot_par=True,
exact=info.exactSolution, linestyle='-', marker='.')
For more examples, see the demos folder.
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
Built Distribution
Close
Hashes for CUQIpy-FEniCS-0.2.1.post0.dev7.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f59c47ffc6e5976091b885b3d9d9a77f5674cebbdd2505147c6e1dfca84a3a35 |
|
MD5 | cc5cd942d8fc07d5a58bb57a9af2a07f |
|
BLAKE2b-256 | ba504e776763d8c1c10663d3b76d7a3d4a5b977ad22176036fafc53dc699e72b |
Close
Hashes for CUQIpy_FEniCS-0.2.1.post0.dev7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b847822e640381d99cc7c278deab5b8ea517c485f31efe1ff150cf75a19ac426 |
|
MD5 | f0bf9e5286e0cc15b8db18e0cd51bb96 |
|
BLAKE2b-256 | 7a067e022828232271b40c7bb7ced01b181d91e8bd9b1c12c6ac827d2e7166da |