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.4.0.post0.dev45.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffbc5fa585599d759420955bb3883f70a3f43bceb4b2c5ad260c1cd4da9ec691 |
|
MD5 | d9aa996b5ef4d2deb4e66bf229e47828 |
|
BLAKE2b-256 | a35fb834438f2097e8da421ad559d5f2b4d990316b823c9eaa08c2e80e72fad8 |
Close
Hashes for CUQIpy_FEniCS-0.4.0.post0.dev45-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30ddcf8a1e95be9e953b25554d8f8587b1b7dc6bbc19670440e75eceed87d706 |
|
MD5 | 4caad61c8dde987ded19fa9991e214d8 |
|
BLAKE2b-256 | 32de8abf6a28abff0301c96972ae38c3c2d1d652e797d74b090d86eb9c402e7c |