fips.Posterior.with_gamma#
- Posterior.with_gamma(gamma)[source]#
Return the posterior of the same problem with another regularization factor.
fips.solve()factors the analytic method’s matrix by Cholesky at its own gamma. The first call eigendecomposes it (about the cost of a solve) and keeps that, since the eigendecomposition reads the factors at any gamma: every later call on this posterior, or on one it returned, costs \(O(m n)\) at most, so a sweep over gamma eigendecomposes once.- Parameters:
gamma (
float) – The regularization factor, asfips.solve(problem, gamma=...)takes it.- Returns:
The posterior
fips.solve(problem, gamma=gamma)would give, its estimate computed.- Return type:
- Raises:
TypeError – If the method cannot change gamma without solving again (its solution has no
with_gamma).
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) >>> [round(post.with_gamma(g).dofs, 3) for g in (0.1, 1.0, 10.0)] [1.25, 1.877, 1.987]