fips.Problem.predict#

Problem.predict(x)[source]#

Return the observations the state x models, \(H x + c\).

Parameters:

x (Vector) – A state on the prior’s labels, in any order: the prior, a posterior estimate, a truth to test with.

Returns:

\(H x + c\) (with the offset \(c\), if any) on the observations’ space.

Return type:

Vector

Raises:
  • TypeError – If x is not a Vector.

  • ValueError – If x does not have exactly the prior’s labels; the message names those on one side only.

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(1.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(0.3),
...     forward=fips.Operator(
...         np.array([[1.0, 0.0], [0.0, 1.0], [1.0, 1.0]]),
...         obs.space,
...         prior.space,
...     ),
...     offset=0.5,
... )
>>> problem.predict(problem.prior).values
array([1.5, 1.5, 2.5])