fips.Posterior#
- class fips.Posterior(problem, solution, options)[source]#
The solution of an inverse problem, labeled.
fips.solve()builds it; there is no need to build one by hand. It keeps what the method kept from the solve (itsSolution), and each output is computed from it when first asked for, labeled with the problem’s spaces, then kept. For the"analytic"method the posterior is Gaussian:estimateis its mean (someanis the same object), and the posterior covariance is \(\hat{S} = (H^T S_z^{-1} H + S_0^{-1})^{-1}\), with \(S_z\) divided by the regularization factor \(\gamma\). It holds what depends on the solve or on them x minnovation covariance (innovation_cov); what needs neither is on theProblem(predict()).Every member works for every method, except four that need more of the method than a
Solutiongives:mean(where the estimate is the mean),with_gamma()andwith_data()(where the method can answer without solving again), andrecovery()(where the estimate is linear in the observations). The analytic method has all four.- Parameters:
problem (
Problem) – The problem that was solved.solution (
Solution) – What the method kept from the solve, which gives the unlabeled arrays (for the analytic method, a factorization:fips.methods.analytic.WhitenedorInformation).options (
Options) – The options of the method, such asfips.methods.analytic.AnalyticOptions.
See also
fips.solveSolve a problem and return its posterior.
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) >>> post.estimate.values.round(3) array([0.997, 1.906]) >>> round(post.dofs, 3) 1.877
Attributes
the sum of the data and the state misfits. |
|
Degrees of freedom for signal, the trace of |
|
the diagonal of |
|
The posterior state estimate, \(\hat{x}\), on the prior's space. |
|
The Shannon information content of the observations about the state, in nats. |
|
The covariance of the innovation, \(H S_0 H^T + S_z / \gamma\), dense. |
|
The gain \(K\), state by observations, dense. |
|
The posterior mean, |
|
The observations the estimate models, \(H \hat{x} + c\). |
|
The options the method solved with ( |
|
The problem that was solved. |
|
The R² of the enhancement, \(\operatorname{corr}(z - c, H\hat{x})^2\). |
|
|
|
The root mean square of the observations minus |
|
One minus the ratio of the posterior to the prior total error. |
|
The posterior error variances, the diagonal of \(\hat{S}\). |
Methods
|
Return the averaging kernel, of the state or of aggregates of it. |
|
Return what each group of candidate observations, not in the problem, would add to the certainty of each aggregate. |
Test whether the innovation, the residual and the increment are as large as the covariances say: Rodgers' four chi-squared tests. |
|
|
Return the posterior error covariance, of the state or of aggregates of it. |
|
Return what each group of observations adds to the certainty of each aggregate, and its share of DOFS. |
|
Compare the observation error variances Desroziers et al. (2005) diagnose with those the solve used. |
|
Return the leverage matrix of the state x: which observations weigh most on it. |
|
Return how well the estimate recovers the truth when the data come from world: exactly, without sampling. |
|
Return the diagnostics of the solve as a table of one row. |
|
Return the prior and posterior uncertainty of each aggregate, and how much the observations reduce it. |
|
Return the posterior of the same problem with other observations. |
|
Return the posterior of the same problem with another regularization factor. |