Algorithm Search⌘K

Algorithmadvanced

Subspace blind channel identification

Also called Moulines subspace method.

Identifies a multichannel FIR channel, up to one scalar, from the noise subspace of the covariance of an oversampled output. It needs subchannels with no common zero and a known channel length.

Time
O(K P^2 N^2 + P^3 N^4) worst
Space
O(P^2 N^2) extra
Where
K = the number of samples; L = the number of channel taps; N = the window length in symbols; P = the number of subchannels
Properties
blinddeterministicneeds known orderofflinesecond order statistics
Origin
Eric Moulines, Pierre Duhamel, Jean Francois Cardoso, Sylvie Mayrargue, 1995

Subspace blind channel identification estimates a channel with one input and P≥2P \ge 2 outputs, such as an oversampled or multi-antenna receiver, from the covariance of the received signal alone. It stacks NN consecutive output vectors into one long vector, whose covariance is HNHNH+σ2IH_N H_N^H + \sigma^2 I for a block Toeplitz matrix HNH_N built from the channel. The eigenvectors of the smallest eigenvalues, the noise subspace, are orthogonal to every column of HNH_N. That orthogonality is a set of linear equations in the channel taps, and the solution is the eigenvector of the smallest eigenvalue of a small matrix QQ. The result is exact, up to one complex scalar, when the subchannels have no common zero and the covariance is exact. It solves the blind equalization problem by identification, not by adapting an equalizer, and it uses only second-order statistics, unlike CMA. It differs from Tong-Xu-Kailath identification, which uses the correlations at lags 0 and 1, whitens the signal part and assumes a white input. The subspace method uses only the lag-0 covariance of a stacked window, needs no whitening, and works for any input covariance of full rank. Both need the channel length.

In plain words

When a receiver takes two or more samples per symbol, it sees the same symbols through two or more slightly different channels. The received vectors then lie close to a smaller set of directions that the channel fixes, and the directions left over contain only noise. The method finds these leftover directions from the measured correlations of the received signal. Every leftover direction must be at right angles to the channel's own directions, and this gives enough equations to find the channel, apart from one unknown factor. It fails when all the channels share a common zero, because then two different channels give the same correlations.

The problem

The received vectors are

y[k]=∑l=0L−1h(l) a[k−l]+w[k]∈CP,y[k] = \sum_{l=0}^{L-1} h(l)\, a[k-l] + w[k] \in \mathbb{C}^P,

with an unknown channel h(0),…,h(L−1)∈CPh(0), \ldots, h(L-1) \in \mathbb{C}^P, independent symbols a[k]a[k] of unit power, and white noise of power σ2\sigma^2 on each output. The stacked channel is h=(h(0);…;h(L−1))∈CPLh = (h(0); \ldots; h(L-1)) \in \mathbb{C}^{PL}. Subchannel pp has the transfer function Hp(z)=∑lhp(l)z−lH_p(z) = \sum_l h_p(l) z^{-l}. The input is the samples y[0],…,y[K−1]y[0], \ldots, y[K-1], the number PP of subchannels, the channel length LL and a window length N≥LN \ge L. The output is h^=βh\hat h = \beta h for an unknown scalar β\beta, with ∥h^∥=1\|\hat h\| = 1.

The stacked model. The window Y[k]=(y[k];y[k−1];…;y[k−N+1])∈CPNY[k] = (y[k]; y[k-1]; \ldots; y[k-N+1]) \in \mathbb{C}^{PN} equals HN (a[k],…,a[k−N−L+2])TH_N\, (a[k], \ldots, a[k-N-L+2])^T plus noise, where HNH_N is the PN×(N+L−1)PN \times (N+L-1) block Toeplitz matrix whose block (i,m)(i, m) is h(m−i)h(m - i), and zero outside 0≤m−i≤L−10 \le m - i \le L - 1. So R=E[YYH]=HNHNH+σ2IR = E[Y Y^H] = H_N H_N^H + \sigma^2 I.

The algorithm

  1. SUBSPACE-IDENTIFY(y, P, L, N)
  2. 1R ← (1/K') Σ_k Y[k] Y[k]^H ▷ sample covariance of the windows
  3. 2G ← eigenvectors of R for its PN - (N+L-1) smallest eigenvalues
  4. 3Q ← the PL × PL zero matrix
  5. 4for each g in G do
  6. 5build 𝒢(g): row m, for m = 0..N+L-2, is (g_m^H, g_{m-1}^H, ..., g_{m-L+1}^H), with g_i = 0 outside 0..N-1
  7. 6Q ← Q + 𝒢(g)^H 𝒢(g)
  8. 7ĥ ← the unit eigenvector of Q for its smallest eigenvalue
  9. 8return ĥ

Line L1 estimates RR from the K′=K−N+1K' = K - N + 1 windows. Line L2 takes the noise subspace: HNH_N has rank N+L−1N + L - 1, so RR has PN−(N+L−1)PN - (N+L-1) eigenvalues equal to σ2\sigma^2, and their eigenvectors are orthogonal to the columns of HNH_N. Here gig_i is block ii of gg, a vector of length PP. Line L5 rewrites the condition gHHN=0g^H H_N = 0 as G(g) h=0\mathcal{G}(g)\, h = 0: entry mm of gHHNg^H H_N is ∑lgm−lHh(l)\sum_l g_{m-l}^H h(l). Lines L3 to L6 sum the squared residuals over the noise subspace, so hHQh=∑g∥gHHN∥2h^H Q h = \sum_g \|g^H H_N\|^2, and line L7 minimizes it on the unit sphere. The code solves the two Hermitian eigenproblems with the Jacobi method on the real form (B−CCB)\begin{pmatrix} B & -C \\ C & B \end{pmatrix} of A=B+jCA = B + jC, which has every eigenvalue twice.

Example

A hand case. Two subchannels h1=(1,0.5)h_1 = (1, 0.5) and h2=(0.5,1)h_2 = (0.5, 1), so L=2L = 2, h(0)=(1,0.5)h(0) = (1, 0.5) and h(1)=(0.5,1)h(1) = (0.5, 1). Their zeros are −0.5-0.5 and −2-2: no common zero. With N=2N = 2, the window has length 4 and

H2=(10.500.510010.500.51),H_2 = \begin{pmatrix} 1 & 0.5 & 0 \\ 0.5 & 1 & 0 \\ 0 & 1 & 0.5 \\ 0 & 0.5 & 1 \end{pmatrix},

of rank 3. The noise subspace has dimension 4−3=14 - 3 = 1, spanned by g=(−1,2,−2,1)g = (-1, 2, -2, 1): check gHH2=(−1+1, −0.5+2−2+0.5, −1+1)=0g^H H_2 = (-1 + 1,\ -0.5 + 2 - 2 + 0.5,\ -1 + 1) = 0. So g0=(−1,2)g_0 = (-1, 2) and g1=(−2,1)g_1 = (-2, 1). With h=(x0,x1,x2,x3)h = (x_0, x_1, x_2, x_3), the three rows of line L5 give

−x0+2x1=0,−2x0+x1−x2+2x3=0,−2x2+x3=0.-x_0 + 2x_1 = 0, \qquad -2x_0 + x_1 - x_2 + 2x_3 = 0, \qquad -2x_2 + x_3 = 0.

So x1=x0/2x_1 = x_0/2, x3=2x2x_3 = 2x_2, and the middle equation gives x2=x0/2x_2 = x_0/2: h=x0(1,0.5,0.5,1)h = x_0 (1, 0.5, 0.5, 1), the channel up to a scalar. The vector gg is the cross relation h2∗y1−h1∗y2=0h_2 * y_1 - h_1 * y_2 = 0 between the two outputs, scaled by −2-2.

From samples. For the complex channel h1=(1,0.5+0.2j,−0.3)h_1 = (1, 0.5 + 0.2j, -0.3), h2=(0.4j,1,0.6)h_2 = (0.4j, 1, 0.6), with K=2000K = 2000 QPSK symbols and noise of power 0.010.01 per output, the misalignment 1−∣h^Hh∣2/∥h∥21 - |\hat h^H h|^2 / \|h\|^2 is 2.7×10−42.7 \times 10^{-4} for N=3N = 3 and 2.9×10−42.9 \times 10^{-4} for N=4N = 4 (seed 1, a measurement). With the exact covariance, it is zero to rounding.

A common zero. If both subchannels contain the factor (1−0.5z−1)(1 - 0.5 z^{-1}), for example h1=(1,−0.2,−0.15)h_1 = (1, -0.2, -0.15) and h2=(0.2,0.9,−0.5)h_2 = (0.2, 0.9, -0.5), then QQ has a null space of dimension 2, and line L7 can return any vector in it.

Correctness

Claim. Let P=2P = 2, N≥LN \ge L, h(0)≠0h(0) \ne 0, h(L−1)≠0h(L-1) \ne 0, and let the two subchannels have no common zero. With the exact covariance R=HNRaHNH+σ2IR = H_N R_a H_N^H + \sigma^2 I for any input covariance RaR_a of full rank, the null space of QQ is exactly {βh}\{\beta h\}, so line L7 returns h/∥h∥h / \|h\| up to a unit scalar. This is a theorem. For P>2P > 2 the same holds under the condition that the PP subchannels have no zero common to all of them; that case is the theorem of Moulines and others (1995) and is cited, not proved here.

Key steps. First, HNH_N has full column rank: a vector in its null space gives polynomial identities that, by the coprimality of the subchannels, force it to be zero. So the noise subspace is the whole left null space of HNH_N. Second, the cross-relation vector gg with blocks giH=(h2(i),−h1(i))g_i^H = (h_2(i), -h_1(i)) lies in that null space. For any candidate h′h', the condition gHHN(h′)=0g^H H_N(h') = 0 says h2∗h1′=h1∗h2′h_2 * h'_1 = h_1 * h'_2 as sequences. Since the subchannels are coprime, h1h_1 divides h1′h'_1, and the degree bound forces h′=βhh' = \beta h. The proofs folder has the details.

What it needs. The channel length LL must be right. If LL is too large, the zero padding gives extra solutions, and QQ has a null space of dimension more than 1. The noise must be white with equal power on all outputs, or prewhitened. With a sample covariance, the estimate is consistent as K→∞K \to \infty, because the noise subspace depends continuously on RR when the eigenvalue gap is positive; the error at finite KK is a measurement.

Proof: With exact statistics and two coprime subchannels, the null space of Q is the channel up to a scalarfull

Setting. P=2P = 2. The subchannels are h1,h2h_1, h_2, each with taps 0,…,L−10, \ldots, L-1, and h(l)=(h1(l),h2(l))h(l) = (h_1(l), h_2(l)). Assume h(0)≠0h(0) \ne 0 and h(L−1)≠0h(L-1) \ne 0, so the channel has exactly LL taps. For each pp, let p~p(x)=∑l=0L−1hp(l) xL−1−l\tilde p_p(x) = \sum_{l=0}^{L-1} h_p(l)\, x^{L-1-l}. Its roots are the zeros of Hp(z)=∑lhp(l)z−lH_p(z) = \sum_l h_p(l) z^{-l}, so "no common zero" means that p~1\tilde p_1 and p~2\tilde p_2 are coprime. The window length is N≥LN \ge L. HN(h)H_N(h) is the 2N×(N+L−1)2N \times (N+L-1) block Toeplitz matrix with block (i,m)(i, m) equal to h(m−i)h(m-i). The exact covariance is R=HNRaHNH+σ2IR = H_N R_a H_N^H + \sigma^2 I, with RaR_a positive definite. The case P>2P > 2 is the theorem of Moulines, Duhamel, Cardoso and Mayrargue (1995). It is cited and not proved here. The code tests only P=2P = 2.

Lemma 1 (full column rank). If N≥L−1N \ge L - 1, then HN(h)H_N(h) has rank N+L−1N + L - 1.

Proof. Let HNt=0H_N t = 0 and T(x)=∑m=0N+L−2tmxmT(x) = \sum_{m=0}^{N+L-2} t_m x^m. Row (i,p)(i, p) of HNtH_N t is ∑lhp(l) ti+l\sum_l h_p(l)\, t_{i+l}, which is the coefficient of xi+L−1x^{i+L-1} in T(x) p~p(x)T(x)\, \tilde p_p(x). So, for each pp, the coefficients of degrees L−1,…,N+L−2L-1, \ldots, N+L-2 of Tp~pT \tilde p_p vanish. Since deg⁡(Tp~p)≤N+2L−3\deg(T \tilde p_p) \le N + 2L - 3, we can write Tp~p=Ap+xN+L−1BpT \tilde p_p = A_p + x^{N+L-1} B_p with deg⁡Ap≤L−2\deg A_p \le L - 2. Then

A1p~2−A2p~1=xN+L−1(B2p~1−B1p~2),A_1 \tilde p_2 - A_2 \tilde p_1 = x^{N+L-1} (B_2 \tilde p_1 - B_1 \tilde p_2),

because both sides equal Tp~1p~2T \tilde p_1 \tilde p_2 minus the same terms. The left side has degree at most 2L−32L - 3. The right side is zero or has degree at least N+L−1≥2L−2N + L - 1 \ge 2L - 2. So both sides are zero, and A1p~2=A2p~1A_1 \tilde p_2 = A_2 \tilde p_1.

Because h(0)≠0h(0) \ne 0, some pp, say p=1p = 1, has h1(0)≠0h_1(0) \ne 0, so deg⁡p~1=L−1\deg \tilde p_1 = L - 1. Since p~1\tilde p_1 divides A1p~2A_1 \tilde p_2 and is coprime to p~2\tilde p_2, it divides A1A_1. But deg⁡A1≤L−2\deg A_1 \le L - 2, so A1=0A_1 = 0. Then A2p~1=0A_2 \tilde p_1 = 0, so A2=0A_2 = 0. Now Tp~p=xN+L−1BpT \tilde p_p = x^{N+L-1} B_p for both pp. Because h(L−1)≠0h(L-1) \ne 0, some pp has p~p(0)=hp(L−1)≠0\tilde p_p(0) = h_p(L-1) \ne 0. Then xN+L−1x^{N+L-1} divides TT, but deg⁡T≤N+L−2\deg T \le N + L - 2, so T=0T = 0. □\square

Lemma 2 (the noise subspace). The 2N−(N+L−1)2N - (N+L-1) smallest eigenvalues of RR equal σ2\sigma^2, and their eigenvectors span the left null space {g:gHHN=0}\{g : g^H H_N = 0\}.

Proof. S=HNRaHNHS = H_N R_a H_N^H is positive semidefinite with range equal to the range of HNH_N, which has dimension N+L−1N + L - 1 by Lemma 1. So SS has N+L−1N + L - 1 positive eigenvalues, with eigenvectors spanning that range, and the eigenvalue 00 on its orthogonal complement, which is the left null space of HNH_N. Adding σ2I\sigma^2 I shifts every eigenvalue by σ2\sigma^2 and keeps the eigenvectors. □\square

So line L2, with the exact RR, returns a basis of the left null space. The code takes 2k2k real eigenvectors of the real form, which give 2k2k complex vectors spanning the same kk-dimensional complex space.

Lemma 3 (what Q measures). For any h′∈C2Lh' \in \mathbb{C}^{2L}, h′HQh′=∑g∈G∥gHHN(h′)∥2h'^H Q h' = \sum_{g \in G} \|g^H H_N(h')\|^2. So Qh′=0Q h' = 0 if and only if gHHN(h′)=0g^H H_N(h') = 0 for every gg in the span of GG.

Proof. Entry mm of gHHN(h′)g^H H_N(h') is ∑igiHh′(m−i)=∑lgm−lHh′(l)\sum_i g_i^H h'(m - i) = \sum_l g_{m-l}^H h'(l), which is row mm of G(g)\mathcal{G}(g) (line L5) times h′h'. So ∥gHHN(h′)∥2=∥G(g)h′∥2=h′HG(g)HG(g)h′\|g^H H_N(h')\|^2 = \|\mathcal{G}(g) h'\|^2 = h'^H \mathcal{G}(g)^H \mathcal{G}(g) h', and line L6 sums these. QQ is positive semidefinite, so h′HQh′=0h'^H Q h' = 0 if and only if Qh′=0Q h' = 0. The map g↦gHHN(h′)g \mapsto g^H H_N(h') is conjugate linear, so it vanishes on a spanning set if and only if it vanishes on the span. □\square

Theorem. Under the setting above, the null space of QQ is {βh:β∈C}\{\beta h : \beta \in \mathbb{C}\}. So line L7 returns h/∥h∥h / \|h\| times a unit scalar.

Proof. If h′=βhh' = \beta h, then gHHN(h′)=β gHHN(h)=0g^H H_N(h') = \beta\, g^H H_N(h) = 0 for every gg in the left null space, so Qh′=0Q h' = 0 by Lemmas 2 and 3.

Conversely, let Qh′=0Q h' = 0. Define the cross-relation vector cc by its blocks ciH=(h2(i),−h1(i))c_i^H = (h_2(i), -h_1(i)) for 0≤i≤L−10 \le i \le L - 1 and ci=0c_i = 0 for L≤i≤N−1L \le i \le N - 1. This fits because N≥LN \ge L. Entry mm of cHHN(h)c^H H_N(h) is

∑i(h2(i) h1(m−i)−h1(i) h2(m−i)),\sum_i \left( h_2(i)\, h_1(m-i) - h_1(i)\, h_2(m-i) \right),

which is coefficient mm of h2∗h1−h1∗h2=0h_2 * h_1 - h_1 * h_2 = 0. So cc is in the left null space, and by Lemmas 2 and 3, cHHN(h′)=0c^H H_N(h') = 0. The same computation shows that entry mm of cHHN(h′)c^H H_N(h') is coefficient mm of h2∗h1′−h1∗h2′h_2 * h'_1 - h_1 * h'_2. The column index mm runs over 0,…,N+L−2⊇{0,…,2L−2}0, \ldots, N + L - 2 \supseteq \{0, \ldots, 2L - 2\}, which covers every coefficient. So h2∗h1′=h1∗h2′h_2 * h'_1 = h_1 * h'_2. In terms of the reversed polynomials, p~2p~1′=p~1p~2′\tilde p_2 \tilde p'_1 = \tilde p_1 \tilde p'_2, where p~p′\tilde p'_p is formed from hp′h'_p in the same way and has degree at most L−1L - 1.

Take pp with deg⁡p~p=L−1\deg \tilde p_p = L - 1, say p=1p = 1. Then p~1\tilde p_1 divides p~2p~1′\tilde p_2 \tilde p'_1, and since it is coprime to p~2\tilde p_2, it divides p~1′\tilde p'_1. Because deg⁡p~1′≤L−1=deg⁡p~1\deg \tilde p'_1 \le L - 1 = \deg \tilde p_1, we get p~1′=βp~1\tilde p'_1 = \beta \tilde p_1 for a constant β\beta. Then p~1p~2′=βp~1p~2\tilde p_1 \tilde p'_2 = \beta \tilde p_1 \tilde p_2, so p~2′=βp~2\tilde p'_2 = \beta \tilde p_2. So h′=βhh' = \beta h. □\square

Remark (a common zero). If p~1\tilde p_1 and p~2\tilde p_2 share a root z0z_0, write p~p=(x−z0) qp\tilde p_p = (x - z_0)\, q_p and let h′h' be the channel with p~p′=(x−z1) qp\tilde p'_p = (x - z_1)\, q_p for another z1≠z0z_1 \ne z_0. Then p~2p~1′=p~1p~2′\tilde p_2 \tilde p'_1 = \tilde p_1 \tilde p'_2, so the cross relation no longer separates hh from h′h'. In fact no second-order method can separate them when z1=1/zˉ0z_1 = 1/\bar z_0 and the input is white, since the two channels then differ by an allpass factor, up to a scale, and give the same covariance at every lag. The test test_a_common_zero_makes_the_channel_unidentifiable shows that QQ then has a null space of dimension 2.

Remark (sample covariance). With the sample covariance R^\hat R from line L1, R^→R\hat R \to R as K→∞K \to \infty for an ergodic input. The noise subspace is a continuous function of RR while the gap between σ2\sigma^2 and the next eigenvalue is positive, and the null vector of QQ is a continuous function of QQ while the null space has dimension 1. So h^\hat h converges to hh up to the scalar. The rate is not derived here.

Complexity

Line L1 costs O(KP2N2)O(K P^2 N^2). The eigenproblem of line L2 costs O(P3N3)O(P^3 N^3) with a standard Hermitian solver (the Jacobi method in the code costs that per sweep). Lines L3 to L6 handle at most PNPN vectors, each with N+L−1N + L - 1 rows and a rank-one update of O(P2L2)O(P^2 L^2), so O(P3N2L2)≤O(P3N4)O(P^3 N^2 L^2) \le O(P^3 N^4). Line L7 is an eigenproblem of size PLPL. The extra space is O(P2N2)O(P^2 N^2) for RR. All counts are in the real RAM.

Properties

  • Blind and second order. It needs only the covariance, not the alphabet, so it works for any input with a full-rank covariance.
  • One scalar ambiguity. It returns hh up to a complex scalar, the least possible ambiguity for second-order statistics.
  • Batch. It needs a block of samples long enough for a good covariance estimate.
  • Exact with exact statistics. With the true covariance, it returns the true channel up to the scalar.
  • Order sensitive. It needs the exact channel length LL.

Variants and improvements

  • Cross-relation method. Xu, Liu, Tong and Kailath (1995) used the identities hq∗yp=hp∗yqh_q * y_p = h_p * y_q between every pair of outputs directly on the data, which avoids the eigenvectors of RR.
  • Weighted subspace fitting. Weighting the noise vectors by their eigenvalues gives a smaller variance from finite samples.
  • Order estimation. The number of eigenvalues of RR near σ2\sigma^2 gives PN−(N+L−1)PN - (N + L - 1), from which LL can be estimated before line L2.
  • Equalization from the estimate. With h^\hat h, a zero-forcing or MMSE fractionally spaced equalizer can be designed directly; for P≥2P \ge 2 and no common zero, an FIR zero-forcing equalizer exists.
  • Related subspace methods. The idea of splitting the covariance into a signal subspace and a noise subspace is the same as in the MUSIC algorithm for direction finding.

When to use it

Use the subspace method when the receiver has P≥2P \ge 2 samples or antennas per symbol, the channel is fixed over a block, and its length is known or can be estimated. In the example, 2000 symbols already give a small error, and there is no local minimum to get stuck in, as there is for CMA. Do not use it at one sample per symbol, where second-order statistics cannot identify the channel, or when the subchannels are nearly coprime only, such as with little excess bandwidth, where the estimate is poor.

Pitfalls

  • The wrong channel length in lines L2 and L5. Overestimating LL leaves a null space of QQ of dimension more than 1, and line L7 returns a mixture. Underestimating it leaves no exact solution.
  • A small eigenvalue gap in line L2. If the subchannels nearly share a zero, the smallest signal eigenvalue is close to σ2\sigma^2, and the noise subspace is badly estimated.
  • Colored noise. The noise eigenvalues are equal only for white noise of equal power. Prewhiten with the known noise covariance first.
  • Taking each eigenvalue once from the real form. The real form of a complex Hermitian matrix has each eigenvalue twice. Line L2 must take 2(PN−N−L+1)2(PN - N - L + 1) real eigenvectors, not PN−N−L+1PN - N - L + 1.
  • Expecting the scalar. The phase and gain of h^\hat h are arbitrary. A pilot, a decision-directed step or a carrier recovery stage must fix them.

Implementations

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

subspace_channel_identification.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/subspace-channel-identification/. The authors are listed in prov/8ZFGWM.jsonl.

"""Subspace blind identification of a single-input multiple-output FIR channel.

The channel has P outputs (P samples per symbol, or P antennas) and L taps:
y[k] = sum_l h(l) a[k-l] + w[k], with h(l) a vector of length P. The
stacked vector h = (h(0); h(1); ...; h(L-1)) has length P L, so h[l*P + p]
is tap l of subchannel p.

A window of N output vectors Y[k] = (y[k]; y[k-1]; ...; y[k-N+1]) is
H_N (a[k], ..., a[k-N-L+2]) + noise, where H_N is the P N by (N + L - 1)
block Toeplitz matrix whose block (i, m) is h(m - i). If the subchannels
have no common zero and N >= L, H_N has full column rank. Every vector g of
the noise subspace of R = E[Y Y^H] then satisfies g^H H_N = 0, which is a
set of linear equations in h. Their least squares solution with |h| = 1 is
the eigenvector of the smallest eigenvalue of Q = sum_g G(g)^H G(g).

The Hermitian eigenproblems are solved by the cyclic Jacobi method on the
real symmetric matrix [[B, -C], [C, B]] of A = B + j C.
"""

import math


def jacobi_eigh(a: list[list[float]], tol: float = 1e-14, sweeps: int = 100) -> tuple[list[float], list[list[float]]]:
    """Eigenvalues (ascending) and eigenvectors (as lists) of a real symmetric matrix, by cyclic Jacobi rotations."""
    n = len(a)
    m = [list(map(float, r)) for r in a]
    v = [[1.0 if i == k else 0.0 for k in range(n)] for i in range(n)]
    for _ in range(sweeps):
        off = sum(m[i][k] ** 2 for i in range(n) for k in range(n) if i != k)
        if off <= tol * tol * max(1.0, sum(m[i][i] ** 2 for i in range(n))):
            break
        for p in range(n - 1):
            for q in range(p + 1, n):
                if m[p][q] == 0.0:
                    continue
                theta = (m[q][q] - m[p][p]) / (2.0 * m[p][q])
                t = (1.0 if theta >= 0 else -1.0) / (abs(theta) + math.sqrt(theta * theta + 1.0))
                c = 1.0 / math.sqrt(t * t + 1.0)
                s = t * c
                for r in range(n):
                    mrp, mrq = m[r][p], m[r][q]
                    m[r][p], m[r][q] = c * mrp - s * mrq, s * mrp + c * mrq
                for r in range(n):
                    mpr, mqr = m[p][r], m[q][r]
                    m[p][r], m[q][r] = c * mpr - s * mqr, s * mpr + c * mqr
                for r in range(n):
                    vrp, vrq = v[r][p], v[r][q]
                    v[r][p], v[r][q] = c * vrp - s * vrq, s * vrp + c * vrq
    order = sorted(range(n), key=lambda i: m[i][i])
    return [m[i][i] for i in order], [[v[r][i] for r in range(n)] for i in order]


def hermitian_eigh(a: list[list[complex]]) -> tuple[list[float], list[list[complex]]]:
    """Eigenvalues (ascending) and eigenvectors of a Hermitian matrix A = B + j C.

    The real matrix [[B, -C], [C, B]] has each eigenvalue of A twice; an
    eigenvector (x; y) of it gives the eigenvector x + j y of A. The result
    has 2 n entries: each eigenvalue of A appears twice, with eigenvectors u
    and j u (up to rotation within the pair).
    """
    n = len(a)
    big = [[0.0] * (2 * n) for _ in range(2 * n)]
    for i in range(n):
        for k in range(n):
            b, c = complex(a[i][k]).real, complex(a[i][k]).imag
            big[i][k] = b
            big[i + n][k + n] = b
            big[i][k + n] = -c
            big[i + n][k] = c
    vals, vecs = jacobi_eigh(big)
    return vals, [[complex(v[i], v[i + n]) for i in range(n)] for v in vecs]


def block_toeplitz(h: list[complex], p: int, n: int) -> list[list[complex]]:
    """The P N by (N + L - 1) matrix H_N, with block (i, m) equal to h(m - i)."""
    taps = len(h) // p
    cols = n + taps - 1
    out = [[0j] * cols for _ in range(p * n)]
    for i in range(n):
        for l in range(taps):
            for q in range(p):
                out[i * p + q][i + l] = complex(h[l * p + q])
    return out


def stack(y: list[list[complex]], n: int) -> list[list[complex]]:
    """The windows Y[k] = (y[k]; y[k-1]; ...; y[k-N+1]) for k = N-1, ..., len(y)-1."""
    return [[complex(v) for i in range(n) for v in y[k - i]] for k in range(n - 1, len(y))]


def sample_covariance(windows: list[list[complex]]) -> list[list[complex]]:
    """(1/K) sum of Y Y^H over the windows."""
    d = len(windows[0])
    r = [[0j] * d for _ in range(d)]
    for w in windows:
        wc = [v.conjugate() for v in w]
        for i in range(d):
            wi, ri = w[i], r[i]
            for k in range(d):
                ri[k] += wi * wc[k]
    k = len(windows)
    return [[v / k for v in row] for row in r]


def subspace_identify(r: list[list[complex]], p: int, taps: int, n: int) -> list[complex]:
    """Estimate h (length P L, unit norm, up to a complex scalar) from the covariance R of the windows of N outputs."""
    if p < 2 or taps < 1 or n < taps or len(r) != p * n:
        raise ValueError("need P >= 2, N >= L and R of size P N")
    k_noise = p * n - (n + taps - 1)
    if k_noise < 1:
        raise ValueError("no noise subspace: need P N > N + L - 1")
    vals, vecs = hermitian_eigh(r)  # @line L2
    noise = vecs[: 2 * k_noise]  # @line L2
    q = [[0j] * (p * taps) for _ in range(p * taps)]  # @line L3
    for g in noise:  # @line L4
        blocks = [g[i * p : (i + 1) * p] for i in range(n)]
        for m in range(n + taps - 1):  # @line L5
            row = [0j] * (p * taps)  # @line L5
            for l in range(taps):  # @line L5
                if 0 <= m - l < n:  # @line L5
                    for s in range(p):  # @line L5
                        row[l * p + s] = blocks[m - l][s].conjugate()  # @line L5
            rc = [v.conjugate() for v in row]  # @line L6
            for i in range(p * taps):  # @line L6
                for k in range(p * taps):  # @line L6
                    q[i][k] += rc[i] * row[k]  # @line L6
    qvals, qvecs = hermitian_eigh(q)  # @line L7
    h = qvecs[0]  # @line L7
    norm = math.sqrt(sum(abs(v) ** 2 for v in h))  # @line L7
    return [v / norm for v in h]  # @line L8


def identify_from_samples(y: list[list[complex]], p: int, taps: int, n: int) -> list[complex]:
    """Form the sample covariance of the windows (line L1) and run subspace_identify."""
    r = sample_covariance(stack(y, n))  # @line L1
    return subspace_identify(r, p, taps, n)


def q_eigenvalues(r: list[list[complex]], p: int, taps: int, n: int) -> list[float]:
    """The eigenvalues of Q (each twice, ascending), to test identifiability."""
    k_noise = p * n - (n + taps - 1)
    vals, vecs = hermitian_eigh(r)
    q = [[0j] * (p * taps) for _ in range(p * taps)]
    for g in vecs[: 2 * k_noise]:
        blocks = [g[i * p : (i + 1) * p] for i in range(n)]
        for m in range(n + taps - 1):
            row = [0j] * (p * taps)
            for l in range(taps):
                if 0 <= m - l < n:
                    for s in range(p):
                        row[l * p + s] = blocks[m - l][s].conjugate()
            for i in range(p * taps):
                for k in range(p * taps):
                    q[i][k] += row[i].conjugate() * row[k]
    return hermitian_eigh(q)[0]
test_subspace_channel_identification.py 109 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/subspace-channel-identification/. The authors are listed in prov/8ZFGWM.jsonl.

import math
import random

import pytest

from subspace_channel_identification import (
    block_toeplitz,
    hermitian_eigh,
    identify_from_samples,
    q_eigenvalues,
    subspace_identify,
)


def conv(a, b):
    out = [0j] * (len(a) + len(b) - 1)
    for i, x in enumerate(a):
        for k, y in enumerate(b):
            out[i + k] += x * y
    return out


def stack_subchannels(subs):
    # h[l * P + p] is tap l of subchannel p
    return [complex(subs[p][l]) for l in range(len(subs[0])) for p in range(len(subs))]


def exact_covariance(h, p, n, s2):
    hn = block_toeplitz(h, p, n)
    d = len(hn)
    return [[sum(hn[i][m] * hn[k][m].conjugate() for m in range(len(hn[0]))) + (s2 if i == k else 0) for k in range(d)] for i in range(d)]


def misalignment(he, h):
    # 1 - |he^H h|^2 / (|he|^2 |h|^2): 0 when he is a scalar times h
    ip = sum(a.conjugate() * b for a, b in zip(he, h))
    return 1 - abs(ip) ** 2 / (sum(abs(v) ** 2 for v in he) * sum(abs(v) ** 2 for v in h))


H3 = stack_subchannels([[1, 0.5 + 0.2j, -0.3], [0.4j, 1, 0.6]])


def test_hermitian_eigensolver() -> None:
    rng = random.Random(1)
    n = 5
    a = [[0j] * n for _ in range(n)]
    for i in range(n):
        a[i][i] = complex(rng.gauss(0, 1))
        for k in range(i + 1, n):
            a[i][k] = complex(rng.gauss(0, 1), rng.gauss(0, 1))
            a[k][i] = a[i][k].conjugate()
    vals, vecs = hermitian_eigh(a)
    assert all(vals[i] <= vals[i + 1] for i in range(len(vals) - 1))
    for lam, v in zip(vals, vecs):
        av = [sum(a[i][k] * v[k] for k in range(n)) for i in range(n)]
        assert max(abs(x - lam * y) for x, y in zip(av, v)) < 1e-10


def test_hand_example() -> None:
    # subchannels (1, 0.5) and (0.5, 1), N = 2: the noise vector is (-1, 2, -2, 1) up to scale
    h = stack_subchannels([[1, 0.5], [0.5, 1]])
    r = exact_covariance(h, 2, 2, 0.3)
    vals, vecs = hermitian_eigh(r)
    g = vecs[0]
    ref = [-1, 2, -2, 1]
    assert misalignment(g, [complex(v) for v in ref]) < 1e-12
    assert abs(vals[0] - 0.3) < 1e-10
    he = subspace_identify(r, 2, 2, 2)
    assert misalignment(he, h) < 1e-12


def test_exact_covariance_gives_the_channel_up_to_a_scalar() -> None:
    for n in (3, 4):
        he = subspace_identify(exact_covariance(H3, 2, n, 0.1), 2, 3, n)
        assert misalignment(he, H3) < 1e-12
        assert abs(sum(abs(v) ** 2 for v in he) - 1) < 1e-12


def test_sample_covariance_gives_a_small_error() -> None:
    rng = random.Random(1)
    k = 2000
    s = math.sqrt(0.005)
    a = [complex(rng.choice((-1, 1)), rng.choice((-1, 1))) / math.sqrt(2) for _ in range(k)]
    y = [
        [sum(H3[l * 2 + q] * a[t - l] for l in range(3) if t - l >= 0) + complex(rng.gauss(0, s), rng.gauss(0, s)) for q in range(2)]
        for t in range(k)
    ]
    for n in (3, 4):
        assert misalignment(identify_from_samples(y, 2, 3, n), H3) < 0.005


def test_a_common_zero_makes_the_channel_unidentifiable() -> None:
    common = stack_subchannels([conv([1, -0.5], [1, 0.3]), conv([1, -0.5], [0.2, 1])])
    q_bad = q_eigenvalues(exact_covariance(common, 2, 3, 0.1), 2, 3, 3)
    q_good = q_eigenvalues(exact_covariance(H3, 2, 3, 0.1), 2, 3, 3)
    # each eigenvalue appears twice; entries 0, 1 are the null vector, entries 2, 3 the next one
    assert abs(q_bad[2]) < 1e-10
    assert q_good[2] > 1e-3


def test_bad_input() -> None:
    r = exact_covariance(H3, 2, 3, 0.1)
    with pytest.raises(ValueError):
        subspace_identify(r, 2, 3, 2)
    with pytest.raises(ValueError):
        subspace_identify(r, 1, 3, 6)

History

Tong, Xu and Kailath showed in 1991 that the second-order statistics of a fractionally sampled output identify the channel, which started the second-order blind methods. Moulines, Duhamel, Cardoso and Mayrargue (1995) gave the subspace method, which uses the noise subspace of the stacked covariance, and Xu, Liu, Tong and Kailath (1995) gave the closely related cross-relation method.

References

  1. Eric Moulines, Pierre Duhamel, Jean-Francois Cardoso and Sylvie Mayrargue, Subspace methods for the blind identification of multichannel FIR filters, IEEE Transactions on Signal Processing 43(2), 1995, pages 516 to 525, the block Toeplitz model, its full column rank for a window at least as long as the channel, and the identification of the channel from the noise subspace
  2. Lang Tong, Guanghan Xu and Thomas Kailath, Blind identification and equalization based on second-order statistics: a time domain approach, IEEE Transactions on Information Theory 40(2), 1994, pages 340 to 349, identifiability from second-order statistics when the subchannels have no common zero
  3. Guanghan Xu, Hui Liu, Lang Tong and Thomas Kailath, A least-squares approach to blind channel identification, IEEE Transactions on Signal Processing 43(12), 1995, the cross-relation method, which uses the same identity between pairs of subchannels

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH1 sketch
  • a full proof of time.worst
  • a full proof of space.extra
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a scene preset for the example