fips.solve#
- fips.solve(problem, method='analytic', **options)[source]#
Solve an inverse problem and return its posterior.
The problem is not changed.
- Parameters:
problem (
Problem) – The problem to solve.method (
str) – The name of a method (seeavailable_methods())."analytic"is the closed-form Gaussian posterior.**options (
Any) – The method’s options, by name: for"analytic",gamma(seeAnalyticOptions).
- Returns:
The labeled solution; its estimate is computed before it returns.
- Return type:
- Raises:
ValueError – If method is not a registered name, or an option is unknown to the method or has a value it refuses; the message lists what it knows.
See also
fips.PosteriorWhat it returns.
available_methodsThe names method can be.
Examples
>>> import numpy as np >>> import pandas as pd >>> import fips >>> cells = pd.Index(["a", "b"], name="cell") >>> obs_id = pd.Index(["o1", "o2", "o3"], name="obs_id") >>> prior = fips.Vector.from_series(pd.Series(0.0, index=cells), block="flux") >>> obs = fips.Vector.from_series( ... pd.Series([1.0, 2.0, 3.0], index=obs_id), block="co2" ... ) >>> problem = fips.Problem( ... prior=prior, ... prior_cov=fips.Independent().with_std(1.0), ... obs=obs, ... obs_cov=fips.Independent().with_std(np.sqrt(0.1)), ... forward=fips.Operator( ... np.array([[1.0, 0.0], [0.0, 1.0], [1.0, 1.0]]), obs.space, prior.space ... ), ... ) >>> post = fips.solve(problem, gamma=0.5) >>> post.options AnalyticOptions(gamma=0.5) >>> fips.solve(problem, gama=0.5) Traceback (most recent call last): ... ValueError: Method 'analytic' has no option 'gama'; its options are: gamma.