Tutorials › Multivariate Statistics (Graduate) › Biased and Unbiased HSIC Estimators

Multivariate Dependence Testing · Tutorial 443 of 975

Biased and Unbiased HSIC Estimators

Learn how the two HSIC estimators are constructed, what their finite-sample properties are, and why an unbiased HSIC estimate need not be nonnegative.

Advanced 11 min read

What You'll Learn

  • Express the biased HSIC estimator using centered Gram matrices.
  • Derive an unbiased HSIC estimator from distinct-index sums.
  • Explain the assumptions behind the unbiasedness result.
  • Compare the estimators’ finite-sample properties.
  • Calculate examples where the unbiased estimate is negative or positive.
  • Identify why an unbiased estimate can be negative without contradicting nonnegative population HSIC.

Why HSIC Has Two Sample Estimators

HSIC measures dependence by comparing feature representations of paired observations. Its population value is nonnegative, but estimating it from a finite sample involves choices about how to handle repeated indices and empirical centering. The common biased estimator uses all entries of two Gram matrices, including their diagonals. The unbiased estimator removes self-pairs and adjusts the remaining terms so its expectation equals population HSIC.

These names describe finite-sample bias, not whether an estimate is statistically useful. The biased estimator is always nonnegative, while the unbiased estimator can be negative in a particular sample. The distinction matters when interpreting a computed HSIC value: nonnegativity is a property of the population quantity, not of every unbiased estimate of it.

Setup: Let \((X_1,Y_1),\ldots,(X_n,Y_n)\) be independent and identically distributed copies of \((X,Y)\). Let \(k\) and \(l\) be measurable positive-definite kernels on the spaces of \(X\) and \(Y\), respectively. Assume the expectations defining HSIC are finite; bounded kernels are a sufficient condition. Write \(K_{ij}=k(X_i,X_j)\) and \(L_{ij}=l(Y_i,Y_j)\) for the Gram matrices, and let \(H=I_n-\mathbf{1}\mathbf{1}^{T}/n\) be the centering matrix.

For independent copies \((X',Y')\) and \((X'',Y'')\), the population HSIC functional can be written as

$$ \operatorname{HSIC}(X,Y) =E[k(X,X')l(Y,Y')] +E[k(X,X')]E[l(Y,Y')] -2E[k(X,X')l(Y,Y'')]. $$

In the last term, \((X,Y)\), \(X'\), and \(Y''\) are independent, with \(X'\) and \(Y''\) drawn from their respective marginal distributions. This expression is equivalent to the squared Hilbert–Schmidt norm of the cross-covariance operator when that operator is defined. In particular, population HSIC is nonnegative.

The Biased V-Statistic

The biased estimator is the HSIC functional evaluated at the empirical distribution of the observed pairs. Empirical averaging allows indices to repeat, so the sums include diagonal entries such as \(K_{ii}=k(X_i,X_i)\). In matrix notation, the result is

Definition: The biased, or V-statistic, estimator of HSIC is
$$ \widehat{\operatorname{HSIC}}_{\mathrm{b}} =\frac{1}{n^2}\operatorname{tr}(KHLH) =\frac{1}{n^2}\sum_{i=1}^{n}\sum_{j=1}^{n}(HKH)_{ij}(HLH)_{ij}. $$

The equality follows because \(H\) is symmetric and idempotent: \(\operatorname{tr}(KHLH)=\operatorname{tr}(HKHLH)=\operatorname{tr}((HKH)(HLH))\). The centered Gram matrices \(HKH\) and \(HLH\) are positive semidefinite. Their entrywise inner product, which is the trace above, is nonnegative: for positive semidefinite matrices \(A,B\), \(\operatorname{tr}(AB)=\operatorname{tr}(A^{1/2}BA^{1/2})\geq 0\). Thus the biased estimate cannot be negative.

The estimator is a V-statistic because its sums range over all index tuples, including tuples with repeated indices. The empirical centering and the diagonal terms make it a convenient direct plug-in estimate, but do not make it exactly unbiased at finite \(n\).

Worked Example: A Nonnegative Biased Estimate

Take \(n=4\), use the linear kernel \(k(x,x')=xx'\) for both variables, and observe \(x=y=(1,-1,1,-1)\). The vectors are already centered, so \(HKH=xx^T\) and \(HLH=yy^T\). Therefore,

$$ \widehat{\operatorname{HSIC}}_{\mathrm{b}} =\frac{\operatorname{tr}(xx^Tyy^T)}{16} =\frac{(x^Ty)^2}{16} =\frac{(4)^2}{16}=1. $$

The estimate is nonnegative, as the general matrix argument requires. This calculation also shows how, for linear kernels, empirical HSIC is the square of the empirical cross-covariance with the normalization used here.

The Unbiased U-Statistic

To remove finite-sample bias, estimate the three expectations in the population formula using only distinct observations. Define the following sums, with every index in each sum distinct:

$$ A_n=\frac{1}{n(n-1)}\sum_{i\ne j}K_{ij}L_{ij},\qquad B_n=\frac{1}{n(n-1)(n-2)(n-3)} \sum_{\substack{i\ne j,\ q\ne r\\ i,j,q,r\ \mathrm{all\ distinct}}}K_{ij}L_{qr}, $$
$$ C_n=\frac{1}{n(n-1)(n-2)} \sum_{\substack{i,j,q\\ i,j,q\ \mathrm{all\ distinct}}}K_{ij}L_{iq}. $$

Here \(A_n\) estimates the first expectation, \(B_n\) estimates the product of marginal expectations, and \(C_n\) estimates the final expectation in the population expression. For example, in a summand of \(C_n\), the shared anchor observation \(i\) supplies \(X_i\) and \(Y_i\), while observations \(j\) and \(q\) supply independent draws of \(X'\) and \(Y''\).

Theorem: If \(n\geq 4\) and the sampled pairs are independent and identically distributed, then
$$ \widehat{\operatorname{HSIC}}_{\mathrm{u}}=A_n+B_n-2C_n $$
is unbiased for population HSIC, provided the expectations in its definition are finite.

Proof. For every summand in \(A_n\), the two observations are independent copies of \((X,Y)\). Hence \(E[K_{ij}L_{ij}]=E[k(X,X')l(Y,Y')]\), so \(E[A_n]\) equals the first population term. In every summand of \(B_n\), the two kernel factors are formed from four distinct independent observations. Thus \(E[K_{ij}L_{qr}]=E[k(X,X')]E[l(Y,Y')]\), and \(E[B_n]\) equals the second term. In every summand of \(C_n\), the three distinct observations have the roles described above, so \(E[K_{ij}L_{iq}]=E[k(X,X')l(Y,Y'')]\). Consequently, taking expectations of \(A_n+B_n-2C_n\) gives exactly the population formula. \(\square\)

A common matrix form makes this estimator easier to compute. Let \(K^{0}\) and \(L^{0}\) equal \(K\) and \(L\) off the diagonal and have zero diagonal. Then

Equivalent formula: For \(n\geq 4\),
$$ \widehat{\operatorname{HSIC}}_{\mathrm{u}} =\frac{1}{n(n-3)} \left[ \operatorname{tr}(K^{0}L^{0}) +\frac{(\mathbf{1}^{T}K^{0}\mathbf{1})(\mathbf{1}^{T}L^{0}\mathbf{1})}{(n-1)(n-2)} -\frac{2}{n-2}\mathbf{1}^{T}K^{0}L^{0}\mathbf{1} \right]. $$

This formula is obtained by expanding the distinct-index sums and collecting terms according to which indices coincide. In particular, the product of the two off-diagonal totals contains both disjoint index pairs and pairs that overlap; the row-sum correction removes the unwanted overlap contributions. The zero diagonals are part of the formula. Substituting the original Gram matrices without zeroing their diagonals does not give this U-statistic.

Worked Example: An Unbiased Estimate That Is Negative

Use \(n=4\) and the linear kernels \(k(x,x')=xx'\), \(l(y,y')=yy'\), with \(x=(1,-1,0,0)\) and \(y=(1,1,-1,-1)\). Both vectors have mean zero and \(x^Ty=0\), so the biased estimate is \((x^Ty)^2/16=0\).

For the unbiased formula, the off-diagonal totals are \(\mathbf{1}^{T}K^{0}\mathbf{1}=(\sum_i x_i)^2-\sum_i x_i^2=-2\) and \(\mathbf{1}^{T}L^{0}\mathbf{1}=(\sum_i y_i)^2-\sum_i y_i^2=-4\). The trace term is \[ \operatorname{tr}(K^{0}L^{0})=(x^Ty)^2-\sum_i x_i^2y_i^2=-2. \] The row-sum product term is \(\mathbf{1}^{T}K^{0}L^{0}\mathbf{1}=2\): the \(i\)th off-diagonal row sums are \(-x_i^2\) and \(-y_i^2\), whose products sum to \(\sum_i x_i^2y_i^2=2\). Therefore,

$$ \widehat{\operatorname{HSIC}}_{\mathrm{u}} =\frac{1}{4}\left[-2+\frac{(-2)(-4)}{6}-2\right] =-\frac{2}{3}. $$

The negative value does not conflict with the nonnegativity of population HSIC. Unbiasedness says that the estimate’s expectation across repeated samples equals the population value; it does not require every sample estimate to be nonnegative.

Worked Example: Positive and Negative Estimates on Two Samples

Return to \(n=4\) and the linear-kernel data \(x=y=(1,-1,1,-1)\). For the unbiased formula, each off-diagonal total is \(-4\), the trace term is \(12\), and the row-sum product term is \(4\). The row-sum value follows because each off-diagonal row sum is \(-1\), giving four products equal to \(1\). Thus

$$ \widehat{\operatorname{HSIC}}_{\mathrm{u}} =\frac{1}{4}\left[12+\frac{16}{6}-4\right] =\frac{8}{3}. $$

For this sample the biased estimate was \(1\), while the unbiased estimate is \(8/3\). Together with the negative estimate in the preceding example, this illustrates that the unbiased estimator can fall below or above the nonnegative plug-in estimate in a particular sample. Neither comparison implies that one estimate must always be larger than the other.

Finite-Sample Interpretation and a Common Pitfall

The V-statistic uses empirical centering and all \(n^2\) observation pairs, including self-pairs. It is nonnegative and is often convenient for reporting or computation, but its finite-sample expectation need not equal population HSIC. The U-statistic excludes diagonal terms and corrects for the resulting index overlaps. It is unbiased under the independent and identically distributed sampling assumption, but it may have higher variability and may be negative.

Common mistake: “HSIC is nonnegative, so a negative unbiased HSIC estimate must be a coding error.” This reasoning confuses a population quantity with an unbiased estimate based on one random sample. The population value is nonnegative; unbiasedness constrains the average of the estimator over repeated samples, not its sign in each sample. A negative estimate should prompt checks of the zero-diagonal convention and the formula, but it is not by itself evidence of an error.

A second practical error is to treat the two estimates as interchangeable without recording which one was used. Their finite-sample values can differ substantially, and a reported number should identify the estimator. The unbiased formula also requires \(n\geq4\); its denominators do not define an estimator for smaller samples.

Key takeaway: The biased V-statistic is a nonnegative empirical plug-in estimate. The unbiased U-statistic uses distinct observations and has expectation equal to population HSIC, but individual estimates can be negative. Their finite-sample behavior follows from how each handles repeated indices.

Check Your Understanding

Answer these questions using the formulas and assumptions above.

  1. Why does the biased estimator include diagonal Gram-matrix entries?
  2. Which population term is estimated by the distinct-four-index sum \(B_n\)?
  3. What independence assumption justifies the expectation of a summand in \(C_n\)?
  4. Why can an unbiased estimate of a nonnegative population HSIC value be negative?
  5. What must be done to the Gram-matrix diagonals before using the stated matrix formula for the unbiased estimator?
Clinical Biostats