virgil._linear
Internal module
virgil._linear is a private implementation detail, documented for
contributors and for reading the source; its API may change without
deprecation. Users reach it through
OIData.with_gains,
OIData.with_flux_scale,
OIData.with_continuum and
RVData.term(marginalize_offsets=...).
Analytic marginalization of parameters that enter the model linearly: the
calibration gains and closure-phase offsets of
virgil.gains, the grey scales and continuum terms of
virgil.observables, and the RV zero points of
RVData. The prior is always stated by the caller,
never taken from the data, and a Gaussian on a scale-type parameter is a
proposal for its Jeffreys prior.
Analytic marginalization of parameters that enter the model linearly.
The data are d = m + A w + n with noise N(0, D) and a stated
Gaussian prior w ~ N(μ, Λ), so d ~ N(m + A μ, D + A Λ Aᵀ). In
whitened coordinates x = D^-½ (d - m - A μ) and U = D^-½ A Λ^½ the
covariance is I + U Uᵀ, and everything here works on (x, U): it
returns a whitened residual of the length of x and the log-determinant
½ log det(I + UᵀU), which must be kept (it depends on the model).
The prior must be stated, finite and independent of the data. A Gaussian on a positive scale parameter is a proposal only (reweight to Jeffreys).
Two whitenings agree: successive rank-one steps (whiten_rank_one,
whiten_blocks; smooth gradients for degenerate columns; for gains,
offsets and grey scales) and a dense Cholesky (whiten_cholesky; a few
well-conditioned columns). LinearMarginal wraps either.
Derivations and rules: design/linear_marginalisation.md.
LinearMarginal
Bases: Module
A design A whose parameters w are marginalized under a stated prior.
The prior must be finite (a flat prior is not supported); a Gaussian on a scale-type parameter is a proposal only (reweight to Jeffreys).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
design
|
array - like
|
|
required |
prior_mean
|
array - like
|
|
required |
prior_sd
|
array - like
|
Prior standard deviations |
None
|
prior_cov
|
array - like
|
A full prior covariance |
None
|
method
|
(cholesky, rank_one)
|
|
"cholesky"
|
design = design
instance-attribute
prior_mean = mean
instance-attribute
prior_root = root
instance-attribute
method = method
class-attribute
instance-attribute
__init__(design, prior_mean, prior_sd=None, prior_cov=None, method='cholesky')
standardize(resid, sigma)
(x, U) for residuals resid = d - m and errors sigma.
whiten(resid, sigma)
Whitened residuals and the log-normalization.
Returns:
| Type | Description |
|---|---|
tuple
|
|
loglike(resid, sigma)
The normalized Gaussian log density of the marginalized data.
posterior(resid, sigma)
Conditional posterior of w: (mean, cov), in w's own units.
whiten_blocks(x, rows, local, spanning=None)
Whiten x for I + Σ w_j w_jᵀ by rank-one steps, block by block.
rows (n_block, n_row) indexes x (padded out of range),
local (n_block, n_row, n_mode) holds each block's columns, and
spanning (n, n_spanning) columns across blocks, whitened after.
Returns:
| Type | Description |
|---|---|
tuple
|
The whitened |
whiten_rank_one(x, U)
Whiten x for I + U Uᵀ by successive rank-one steps.
Returns:
| Type | Description |
|---|---|
tuple
|
The whitened |
whiten_cholesky(x, U)
Whiten x for I + U Uᵀ with a dense k × k Cholesky.
Returns:
| Type | Description |
|---|---|
tuple
|
The whitened |
posterior(x, U)
Conditional posterior N(S⁻¹ Uᵀ x, S⁻¹), S = I + UᵀU, of ω.
ω is the standardized parameter, w = μ + Λ^½ ω.
Returns:
| Type | Description |
|---|---|
tuple
|
|