Stacked visibilities, circular complex Gaussian noise and white-noise likelihood for SAGE calibration
DefinitionArxiv0810_5751_BasicObjects of Sections II-IV of Yatawatta, Zaroubi, de Bruyn, Koopmans and Noordam (2008).
- Stacked data (Section II). An array has dual-polarised stations. A baseline is a pair with ; autocorrelations are ignored. For a set of baselines, the data vector stacks the four entries of of each visibility matrix , ; its length is , the size of the index set .
- Circular complex Gaussian law. A random vector is zero-mean circular complex Gaussian with covariance if for every . For positive definite this is the law with density used in eq. (15).
- EM noise split (eq. (8)). For weights and an covariance , the stacked noise components have covariance .
- Residual. For source contributions , , and , the residual is and .
- Likelihood (eqs. (15)-(16)). , and for white noise the log-likelihood is .
- Section IV estimates. (eq. (17)); (eq. (18)); (eq. (19)).
Formalization Note The paper writes and uses the circular density (15); the definition makes circularity explicit through the characteristic function. The determinant and the quadratic form in (15) are taken as real parts, which they are for Hermitian . The covariance is written Pcov in Lean.
import Mathlib
/-!
Yatawatta, Zaroubi, de Bruyn, Koopmans and Noordam, *Radio interferometric calibration using the
SAGE algorithm*, arXiv:0810.5751v1 (2008), 13th IEEE DSP Workshop (2009): the stacked
cross-correlation data of Section II (eqs. (2)-(4)), the circular complex Gaussian noise model of
Sections II-III (eqs. (4), (8), (15)), and the white-noise likelihood, maximum-likelihood noise
variance, concentrated log-likelihood and Akaike criterion of Section IV (eqs. (5), (15)-(19)).
-/
open MeasureTheory Matrix
noncomputable section
namespace Arxiv0810_5751
/-- Section II, text before eq. (4): the cross-correlation baselines `(p, q)` with `p < q` of an
array of `N` stations (autocorrelations `p = q` are ignored). -/
def crossBaselines (N : ℕ) : Finset (Fin N × Fin N) :=
Finset.univ.filter fun b => b.1 < b.2
/-- Section II, eq. (4): the index set of the stacked data vector `y` built from the baselines in
`B`: each baseline `(p, q)` contributes the four entries of `vec(V_pq)`, `V_pq` a `2 × 2` matrix.
The length `M` of `y` is the cardinality of this type. -/
abbrev VisIndex {N : ℕ} (B : Finset (Fin N × Fin N)) : Type :=
B × (Fin 2 × Fin 2)
/-- Section II, eqs. (2)-(4): the stacked vector `y = [v_12ᵀ v_13ᵀ … v_(N-1)Nᵀ]ᵀ` of the
vectorised visibilities `v_pq = vec(V_pq)` over the baselines in `B`. -/
def stackedVis {N : ℕ} (V : Fin N → Fin N → Matrix (Fin 2) (Fin 2) ℂ)
(B : Finset (Fin N × Fin N)) : VisIndex B → ℂ :=
fun x => V x.1.1.1 x.1.1.2 x.2.1 x.2.2
/-- Section II (`n ∼ N(0, Π)`) and eq. (15): `ν` is the law of a zero-mean circular complex
Gaussian vector with covariance `C = E{z zᴴ}`, characterised by its characteristic function
`E exp(i Re(wᴴ z)) = exp(-wᴴ C w / 4)` for all `w`. For positive definite `C` this is the law with
density `(π^M |C|)⁻¹ exp(-zᴴ C⁻¹ z)` of eq. (15). -/
def IsCircGaussian {ι : Type*} [Fintype ι] (ν : Measure (ι → ℂ)) (C : Matrix ι ι ℂ) : Prop :=
∀ w : ι → ℂ, ∫ z, Complex.exp (Complex.I * ((star w ⬝ᵥ z).re : ℂ)) ∂ν =
Complex.exp (-(1 / 4 : ℂ) * (star w ⬝ᵥ C *ᵥ w))
/-- Section III-A, eq. (8): the covariance `E{ñ_i ñ_jᴴ} = β_i δ_ij Π` of the stacked noise
components `(ñ_1, …, ñ_K)`, as a matrix indexed by (component, data entry). -/
def emNoiseCov {K M : ℕ} (β : Fin K → ℝ) (Pcov : Matrix (Fin M) (Fin M) ℂ) :
Matrix (Fin K × Fin M) (Fin K × Fin M) ℂ :=
fun a b => if a.1 = b.1 then (β a.1 : ℂ) * Pcov a.2 b.2 else 0
/-- Section II, eqs. (4)-(5): the residual `y - ∑_{i=1}^K s_i(θ)` of the data `y ∈ ℂ^M` for the
source contributions `s_i : ℂ^P → ℂ^M` at the parameter `θ ∈ ℂ^P`. -/
def residual {K M P : ℕ} (y : Fin M → ℂ) (s : Fin K → (Fin P → ℂ) → Fin M → ℂ)
(θ : Fin P → ℂ) : Fin M → ℂ :=
y - ∑ i, s i θ
/-- Eqs. (5), (16)-(18): the squared residual norm
`‖y - ∑_i s_i(θ)‖² = (y - ∑_i s_i(θ))ᴴ (y - ∑_i s_i(θ))`. -/
def residSq {K M P : ℕ} (y : Fin M → ℂ) (s : Fin K → (Fin P → ℂ) → Fin M → ℂ)
(θ : Fin P → ℂ) : ℝ :=
∑ m, Complex.normSq (residual y s θ m)
/-- Section IV, eq. (15): the likelihood
`f(y | θ) = (π^M |Π|)⁻¹ exp(-(y - ∑_i s_i(θ))ᴴ Π⁻¹ (y - ∑_i s_i(θ)))` of the observation model (4)
with circular complex Gaussian noise of covariance `Π` (`|Π|` the determinant). -/
def likelihood {K M P : ℕ} (Pcov : Matrix (Fin M) (Fin M) ℂ) (y : Fin M → ℂ)
(s : Fin K → (Fin P → ℂ) → Fin M → ℂ) (θ : Fin P → ℂ) : ℝ :=
(Real.pi ^ M * (Pcov.det).re)⁻¹ *
Real.exp (-(star (residual y s θ) ⬝ᵥ Pcov⁻¹ *ᵥ residual y s θ).re)
/-- Section IV, eq. (16): the log-likelihood `L(θ) = log f(y | θ)` for white noise `Π = σ² I`,
as a function of the noise variance `σ2 = σ²` and the parameter `θ`. -/
def whiteLogLik {K M P : ℕ} (σ2 : ℝ) (y : Fin M → ℂ) (s : Fin K → (Fin P → ℂ) → Fin M → ℂ)
(θ : Fin P → ℂ) : ℝ :=
Real.log (likelihood ((σ2 : ℂ) • (1 : Matrix (Fin M) (Fin M) ℂ)) y s θ)
/-- Section IV, eq. (17): the noise-variance estimate
`σ̂² = (1/M) (y - ∑_i s_i(θ̂))ᴴ (y - ∑_i s_i(θ̂))`. -/
def mlNoiseVar {K M P : ℕ} (y : Fin M → ℂ) (s : Fin K → (Fin P → ℂ) → Fin M → ℂ)
(θ : Fin P → ℂ) : ℝ :=
residSq y s θ / M
/-- Section IV, eq. (18): `L(θ̂) = -M log π - M - M log((1/M)(y - ∑_i s_i(θ̂))ᴴ(y - ∑_i s_i(θ̂)))`. -/
def concLogLik {K M P : ℕ} (y : Fin M → ℂ) (s : Fin K → (Fin P → ℂ) → Fin M → ℂ)
(θ : Fin P → ℂ) : ℝ :=
-(M : ℝ) * Real.log Real.pi - M - M * Real.log (residSq y s θ / M)
/-- Section IV, eq. (19): Akaike's criterion `AIC(K) = -2 L(θ̂) + 2(2P)` for the model with `K`
sources and `P` complex parameters (`2P` real parameters), with `L(θ̂)` as in eq. (18). -/
def aic {K M P : ℕ} (y : Fin M → ℂ) (s : Fin K → (Fin P → ℂ) → Fin M → ℂ)
(θ : Fin P → ℂ) : ℝ :=
-2 * concLogLik y s θ + 2 * (2 * P)
end Arxiv0810_5751
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
crossBaselines. For a natural number , this is the finite set of ordered pairs of station indices
Indices start at , so station is one of . Pairs with and pairs with are excluded. The set has elements and is empty when or .
VisIndex. Let be a natural number and any finite set of ordered pairs with . need not be ; it may contain pairs with , and it may be empty. Then is the finite index set
It has exactly elements and is empty if is empty. No ordering of these indices is specified.
stackedVis. The inputs are:
- a natural number ;
- an assignment giving a complex matrix to every ordered pair with , including and ;
- a finite set of such pairs.
The stacked data is the complex-valued function on given by
Here is the entry of in row , column , with rows and columns indexed from . So just collects the four entries of each with . It is a function on an unordered finite index set, not a column vector with a prescribed stacking order. Values of at pairs outside are not used.
IsCircGaussian. Let be any finite index set (possibly empty), any measure on , and any complex matrix. No Hermitian, positive-semidefinite or invertibility assumption is made on . The predicate holds exactly when, for every ,
In this formula:
- ;
- , a complex number that may be non-real if is not Hermitian;
- the integral is the Lebesgue–Bochner integral of a complex-valued function, which by convention is when the integrand is not integrable.
Taking gives . Under these integral conventions this forces to be a probability measure, since the integral of over a measure of infinite total mass is taken to be . Nothing about densities, means, or being the actual covariance is stated separately; the predicate is exactly this characteristic-function identity.
emNoiseCov. The inputs are natural numbers , a real vector , and a complex matrix . No sign, normalization or other constraint is placed on or . The output is the complex matrix indexed by pairs with and , with entries
Equivalently, it is the block-diagonal matrix . It is the empty matrix if or .
residual. The inputs are:
- natural numbers ;
- a data vector ;
- arbitrary functions , with no continuity or other assumption;
- a parameter .
The residual is the vector
When the sum is empty and .
residSq. With , , arbitrary and as above, this is the nonnegative real number
It equals when .
likelihood. The inputs are an arbitrary complex matrix and , , , as above. No Hermitian, positivity or invertibility assumption is made on . With , the real number defined is
Only the real part of and the real part of the quadratic form are used. Three conventions affect the value:
- is the usual inverse when and the zero matrix when .
- is taken to be for , so whenever .
- If the value is negative.
For , and the value is .
whiteLogLik. The inputs are a real number (an arbitrary real, possibly zero or negative) and , , , as above. The value is of the likelihood above with . Here denotes the real logarithm extended by for and . Unfolding, there are three cases:
- If :
- If and , the determinant vanishes, the likelihood is , and .
- If , then .
mlNoiseVar. For , , as above and an arbitrary , this is the real number
When the value is , by the convention that division by zero gives . is any parameter: it is not required to be a maximizer or estimate of anything, and nothing is asserted about this quantity maximizing a likelihood.
concLogLik. For , , as above and an arbitrary , this is the real number defined directly by the formula
It is not defined as an evaluation of whiteLogLik, and is not required to be a maximizer. Two edge cases follow from the conventions and :
- If and , then .
- If , then .
aic. For , , as above and an arbitrary , this is the real number
where is the concLogLik value above, with its conventions for and . The penalty term depends only on the length of the parameter vector . The number of sources enters only through the sum inside the residual, not through the penalty.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.