Problem#
A Problem holds the inputs of a linear inverse problem: the prior and
its covariance, the observations and theirs, the forward operator and an
optional offset. It checks their labels once, when it is built, by an exact
join: the forward operator, a covariance or the offset must have exactly the
labels of the prior or of the observations, in any order, or it raises
naming the blocks and labels on one side only. A covariance model is built on
the prior’s or the observations’ space. solve() solves a problem.
Problem.restrict() holds part of the state at its prior (the cells no
observation sees well), and Problem.aggregate() aggregates the
observations (see Aggregation and Offsets).
See also
See Terminology for definitions of prior, posterior, forward operator, and other inverse problem terminology.
In [1]: import numpy as np
In [2]: import pandas as pd
In [3]: import fips
In [4]: cells = pd.Index(["a", "b"], name="cell")
In [5]: obs_id = pd.Index(["o1", "o2", "o3"], name="obs_id")
In [6]: prior = fips.Vector.from_series(pd.Series(0.0, index=cells), block="flux")
In [7]: obs = fips.Vector.from_series(pd.Series([1.0, 2.0, 3.0], index=obs_id), block="co2")
In [8]: H = fips.Operator(np.array([[1.0, 0.0], [0.0, 1.0], [1.0, 1.0]]), obs.space, prior.space)
In [9]: problem = fips.Problem(
...: prior=prior,
...: prior_cov=fips.Independent().with_std(1.0),
...: obs=obs,
...: obs_cov=fips.Independent().with_std(0.3),
...: forward=H,
...: )
...:
In [10]: problem
Out[10]: Problem(state: Space(flux: 2 x ['cell']), obs: Space(co2: 3 x ['obs_id']))
In [11]: problem.predict(problem.prior)
Out[11]:
Vector(name=None, Space(co2: 3 x ['obs_id']))
block obs_id
co2 o1 0.0
o2 0.0
o3 0.0
dtype: float64
Constructor#
|
A linear inverse problem: what is known before the observations, and the observations. |
Inputs#
The prior state, \(x_0\); its space labels the state. |
|
The prior error covariance, \(S_0\), on the prior's space. |
|
The observations, \(z\); their space labels the observations. |
|
The model-data mismatch, \(S_z\), on the observations' space. |
|
rows on the observations, columns on the prior. |
|
The offset, \(c\), on the observations' space, or None. |
Without a solve#
What needs no solve and no \(m \times m\) matrix is on the problem: what
the problem predicts, a truth and its synthetic observations
(how to use them), and the problems made from it (the
observations aggregated, part of the state held at its prior). What depends on
the solve is on the Posterior.
Return the observations the state x models, \(H x + c\). |
|
|
Return a truth and the observations it would give, \(H x + c + e\). |
Return the problem of aggregated observations. |
|
|
Return the problem on part of the state, the rest held at its prior. |
Serialization#
A problem pickles with the standard library (pickle.dump(problem, file)).