Hellinger distance, rotated coherency matrix, OA estimator and SD-Y4O powers
DefinitionArxiv1504_01000_BasicObjects of Sections II-IV of Bhattacharya, Muhuri, De, Manickam and Frery (2015).
- Hellinger distance (Section II). For distributions on with densities , . This is the distance with , .
- Multilook intensity law (Section II). The Gamma distribution with shape (the number of looks) and mean . Its density is for and for .
- Rotated coherency matrix (eq. 7). For a coherency matrix and an angle ,
The rotated diagonal elements are , and . 4. Hellinger distance of the rotated elements (eq. 9). For and , . The distance curves of the estimator are for . 5. OA estimator (eqs. 9-10, Algorithm 1). The search range is . A candidate angle is a point of of the form or , where is a maximiser over of (giving ) or of (giving ). A candidate is selected when . The final OA is if , if , and otherwise. 6. Relative Hellinger distance (eq. 12). for looks, and . 7. SD-Y4O (eqs. 13a-13d). For Y4O powers and parameters : , , and . The parameter is the linear map , which takes onto .
Formalization Note The paper's indices are Lean's Fin 3 indices . The diagonal elements of are complex numbers in Lean; their real parts are taken, and they are real when is Hermitian. The number of looks is a positive real number, as in Fig. 3, where is a function of . The supremum defining is over all . The paper states the linear map onto without saying which way it runs; it is taken increasing, and .
import Mathlib
/-!
Bhattacharya, Muhuri, De, Manickam and Frery, *Modifying the Yamaguchi Four-Component
Decomposition Scattering Powers Using a Stochastic Distance*, arXiv:1504.01000v1 (2015):
the Hellinger distance and multilook intensity (Gamma) model of Section II, the rotated coherency
matrix and the orientation-angle (OA) estimator of Section III (eqs. (7), (9), (10), Algorithm 1),
and the relative Hellinger distance and SD-Y4O powers of Section IV (eqs. (12), (13a)-(13d)).
Indices: Lean's `Fin 3` indices `0, 1, 2` are the paper's indices `1, 2, 3`, so `T 1 1 = T₂₂`,
`T 2 2 = T₃₃` and `T 1 2 = T₂₃`.
-/
open MeasureTheory
noncomputable section
namespace Arxiv1504_01000
/-- Section II: the Hellinger distance `d_H(D₁, D₂) = 1 - ∫ √(f₁ f₂)` between two distributions on
`ℝ` with densities `f₁, f₂` (obtained from the `(h, φ)` divergence with `h(x) = x/2`,
`φ(x) = (√x - 1)²`). -/
def hellingerDist (f₁ f₂ : ℝ → ℝ) : ℝ :=
1 - ∫ x, Real.sqrt (f₁ x * f₂ x)
/-- Section II, sentence after eq. (6): the multilook intensity law, the Gamma distribution with
shape `L` (number of looks) and expected value `m = σ²`, i.e. rate `L / m`. -/
def intensityPDF (L m : ℝ) (x : ℝ) : ℝ :=
ProbabilityTheory.gammaPDFReal L (L / m) x
/-- Eq. (7): the real rotation matrix
`[U₃(θ)] = [[1, 0, 0], [0, cos 2θ, sin 2θ], [0, -sin 2θ, cos 2θ]]`. -/
def U3 (θ : ℝ) : Matrix (Fin 3) (Fin 3) ℂ :=
!![1, 0, 0;
0, (Real.cos (2 * θ) : ℂ), (Real.sin (2 * θ) : ℂ);
0, -(Real.sin (2 * θ) : ℂ), (Real.cos (2 * θ) : ℂ)]
/-- Eq. (7): the rotated coherency matrix `[T(θ)] = [U₃(θ)] [T] [U₃(θ)]⁻¹`. -/
def rotT (T : Matrix (Fin 3) (Fin 3) ℂ) (θ : ℝ) : Matrix (Fin 3) (Fin 3) ℂ :=
U3 θ * T * (U3 θ)⁻¹
/-- Eq. (7): the diagonal element `σ_l²(θ) = T_ll(θ)` of the rotated coherency matrix (a real
number for Hermitian `T`; its real part is taken). -/
def sigmaSq (T : Matrix (Fin 3) (Fin 3) ℂ) (l : Fin 3) (θ : ℝ) : ℝ :=
(rotT T θ l l).re
/-- Eq. (9): the Hellinger distance between two Gamma laws of common shape `L` and means `a`,
`b`: `1 - [2 √(a b) / (a + b)]^L`. -/
def hellingerGamma (a b L : ℝ) : ℝ :=
1 - (2 * Real.sqrt (a * b) / (a + b)) ^ L
/-- Eq. (9), Algorithm 1: `d_H(σ_l², σ_l²(θ))`, the Hellinger distance between the un-rotated
element `σ_l² = T_ll` and the rotated element `σ_l²(θ)`, as a function of `θ`. -/
def dH (T : Matrix (Fin 3) (Fin 3) ℂ) (L : ℝ) (l : Fin 3) (θ : ℝ) : ℝ :=
hellingerGamma (T l l).re (sigmaSq T l θ) L
/-- Eq. (9): the search range `[-π/4, π/4]` of the OA estimator. -/
def oaRange : Set ℝ :=
Set.Icc (-(Real.pi / 4)) (Real.pi / 4)
/-- Eq. (9) and the paragraph after it: `φ` is a candidate angle, i.e. it lies in `[-π/4, π/4]`
and equals `φ_{3,2}` or `φ_{3,2} ± π/4`, where `φ_{3,2}` is a maximiser over `[-π/4, π/4]` of
`d_H(σ₃², σ₃²(θ))` (that is `φ₃`) or of `d_H(σ₂², σ₂²(θ))` (that is `φ₂`). -/
def IsCandidateOA (T : Matrix (Fin 3) (Fin 3) ℂ) (L : ℝ) (φ : ℝ) : Prop :=
φ ∈ oaRange ∧ ∃ p ∈ oaRange, (IsMaxOn (dH T L 2) oaRange p ∨ IsMaxOn (dH T L 1) oaRange p) ∧
(φ = p ∨ φ = p + Real.pi / 4 ∨ φ = p - Real.pi / 4)
/-- Section III and Algorithm 1: the selection rule. The unwrapped OA `φ` is a candidate angle at
which the Hellinger distance of `σ₃²` exceeds that of `σ₂²`: `d_{Hφ₃} > d_{Hφ₂}`. -/
def IsSelectedOA (T : Matrix (Fin 3) (Fin 3) ℂ) (L : ℝ) (φ : ℝ) : Prop :=
IsCandidateOA T L φ ∧ dH T L 1 φ < dH T L 2 φ
/-- Eq. (10): the final OA `θ₀`, obtained by wrapping `φ` into `[-π/8, π/8]`. -/
def wrapOA (φ : ℝ) : ℝ :=
if φ < -(Real.pi / 8) then φ + Real.pi / 4
else if Real.pi / 8 < φ then φ - Real.pi / 4
else φ
/-- Eq. (12): the relative Hellinger distance
`δ_H = d_H(σ₃², σ₃²(φ)) - d_H(σ₂², σ₂²(φ))` at the angle `φ`, for `L` looks. -/
def deltaH (T : Matrix (Fin 3) (Fin 3) ℂ) (L : ℝ) (φ : ℝ) : ℝ :=
dH T L 2 φ - dH T L 1 φ
/-- Section IV, paragraph after eq. (12): `δ_H^m`, the maximum over the number of looks `L > 0` of
the relative Hellinger distance at `φ`. -/
def deltaHm (T : Matrix (Fin 3) (Fin 3) ℂ) (φ : ℝ) : ℝ :=
⨆ L : Set.Ioi (0 : ℝ), deltaH T L φ
/-- Section IV, eqs. (13a)-(13d): the surface, double-bounce, volume and helix powers
`P_s, P_d, P_v, P_c` of a pixel. -/
structure Y4OPowers where
/-- Surface power `P_s`. -/
ps : ℝ
/-- Double-bounce power `P_d`. -/
pd : ℝ
/-- Volume power `P_v`. -/
pv : ℝ
/-- Helix power `P_c`. -/
pc : ℝ
/-- Eqs. (13a)-(13d): the SD-Y4O powers `P_v^n = P_v (1 - δ)`, `P_d^n = P_d + α P_v δ`,
`P_s^n = P_s + β P_v δ`, `P_c^n = P_c`, where `δ = δ_H^m`. -/
def sdY4O (P : Y4OPowers) (δ α β : ℝ) : Y4OPowers where
ps := P.ps + β * P.pv * δ
pd := P.pd + α * P.pv * δ
pv := P.pv * (1 - δ)
pc := P.pc
/-- Section IV, paragraph after eqs. (13a)-(13d): `α` is obtained by linearly mapping the estimated
OA `φ ∈ [0, π/4]` onto `[0.5, 1.0]`, i.e. `α = 1/2 + 2φ/π`. -/
def alphaOfOA (φ : ℝ) : ℝ :=
1 / 2 + 2 * φ / Real.pi
end Arxiv1504_01000
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
hellingerDist. For any two real functions , this is the real number
where the integral is taken with respect to Lebesgue measure on .
- Nothing requires to be probability densities. They need not be nonnegative, integrable, or normalised.
- Wherever , the square root is taken to be .
- If is not Lebesgue-integrable, the integral is assigned the value , so .
intensityPDF. For real parameters and and a real point , this is the value at of the Gamma density with shape and rate :
- The powers are real powers.
- No positivity is assumed on or .
- If , the rate is taken to be , so . This equals when and when .
- For or , the formula is evaluated as written, using the conventions for at non-positive arguments and for real powers. The result is generally not a probability density.
U3. For a real angle , is the matrix with complex entries (all of which are real numbers)
Rows and columns are indexed by , corresponding to the source's indices .
rotT. For any complex matrix and real angle , the rotated matrix is
- The inverse is the general matrix inverse: the adjugate divided by the determinant, or the zero matrix if the determinant is .
- Since , this is a genuine inverse for every .
- No condition (for example, Hermitian) is imposed on .
sigmaSq. For any complex matrix , index and angle ,
the real part of the diagonal entry of . is not assumed Hermitian, so any imaginary part of the diagonal entry is simply discarded.
hellingerGamma. For real numbers ,
with a real power. No positivity is assumed, and the edge cases are:
- If , then is taken to be .
- If , the quotient is taken to be , and equals for and for .
- If the base is negative (for example, with ), the real power follows the convention .
- For the value is always .
dH. For a complex matrix , a real , an index and an angle ,
This compares the unrotated real diagonal entry with the rotated one, using the formula and all edge-case conventions of above. Index is the source's second diagonal element and is the third.
oaRange. This is the closed interval
IsCandidateOA. For a complex matrix , a real and a real , " is a candidate angle" means both of the following hold:
- .
- There exists some such that:
- either for all , or for all ;
- and .
Some remarks on what this allows:
- The maximiser need not be unique; any maximiser of either function qualifies.
- If neither function attains a maximum on the interval, no angle is a candidate.
- Because of condition 1, can only be a candidate when , and only when .
IsSelectedOA. For , , as above, " is a selected angle" means that is a candidate angle in the sense just described and
(strict inequality). Nothing asserts that a selected angle exists or that it is unique.
wrapOA. For any real (not restricted to any interval),
- The endpoints are left unchanged.
- For inputs in the output lies in .
- For inputs outside the output lies outside .
deltaH. For , real and real ,
with both terms computed using the same . No restriction is placed on or .
deltaHm. For and real ,
the supremum over all strictly positive real (not only integers).
- The supremum need not be attained.
- If the set is not bounded above, the value is taken to be by convention.
- Note that is any real number here; it is not required to be a candidate or selected angle.
Y4OPowers. This is a record of four arbitrary real numbers, , labelled surface, double-bounce, volume and helix power. No constraints such as nonnegativity are imposed.
sdY4O. For any such record and any real numbers , this is the new record with
- , and are free parameters. Nothing ties to or to an angle.
- Nothing requires or any range restriction.
- Total power is preserved exactly when .
alphaOfOA. For any real ,
This is defined on all of , with no restriction to . It sends and , and gives values below for negative and above for .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.