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 (see available_methods()). "analytic" is the closed-form Gaussian posterior.

  • **options (Any) – The method’s options, by name: for "analytic", gamma (see AnalyticOptions).

Returns:

The labeled solution; its estimate is computed before it returns.

Return type:

Posterior

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.

  • TypeError – If problem is not a Problem.

See also

fips.Posterior

What it returns.

available_methods

The 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.