---
title: Conditional Mean Embedding in RKHS
url: https://www.emergentmind.com/topics/conditional-mean-embedding
type: topic
---

# Conditional Mean Embedding in RKHS

Searching arXiv for the cited CME papers to ground the article in current arXiv records.
{"query":"Conditional mean embedding arXiv 1605.09522 1912.00671 2002.03689 1205.4656 2208.01711", "max_results": 10}
Conditional mean embedding (CME) is the reproducing-kernel-Hilbert-space representation of a conditional distribution. Given random variables \(X\) and \(Y\), it associates to each conditioning value \(x\) an element \(\mu_{Y\mid X=x}\in H_Y\) such that conditional expectations of RKHS test functions are recovered by inner products, thereby turning conditioning into a linear-algebraic operation in Hilbert space. In the broader kernel mean embedding program, this extends marginal distribution embeddings to conditional laws and supports nonparametric probabilistic inference, including sum, product, and Bayes’ rules, without explicit density estimation [1605.09522][2002.03689].

## 1. Formal definition and operator formulations

Let \(k_X\) and \(k_Y\) be positive definite kernels on \(\mathcal{X}\) and \(\mathcal{Y}\), with RKHSs \(H_X\) and \(H_Y\), and canonical feature maps \(\phi_X(x)=k_X(x,\cdot)\) and \(\phi_Y(y)=k_Y(y,\cdot)\). The marginal kernel mean embedding is
\[
\mu_X := \mathbb{E}[\phi_X(X)] \in H_X,
\]
and, under the reproducing property, \(\mathbb{E}[f(X)] = \langle f,\mu_X\rangle_{H_X}\) for all \(f\in H_X\). The conditional mean embedding is the \(H_Y\)-valued conditional expectation
\[
\mu_{Y\mid X=x} := \mathbb{E}[\phi_Y(Y)\mid X=x] \in H_Y,
\]
so that
\[
\mathbb{E}[g(Y)\mid X=x] = \langle g,\mu_{Y\mid X=x}\rangle_{H_Y}
\]
for all \(g\in H_Y\). In the measure-theoretic formulation, \(\mu_{Y\mid X}\) is an \(H_Y\)-valued random variable measurable with respect to \(\sigma(X)\), and there exists a measurable function \(F_{P_{Y\mid X}}\) such that \(\mu_{Y\mid X}=F_{P_{Y\mid X}}\circ X\) [2002.03689].

A standard operator-theoretic presentation defines covariance and cross-covariance operators
\[
C_{XX} := \mathbb{E}[\phi_X(X)\otimes \phi_X(X)], \qquad
C_{YX} := \mathbb{E}[\phi_Y(Y)\otimes \phi_X(X)],
\]
or their centered analogues. In the uncentered formulation one writes
\[
U_{Y\mid X} := C_{YX}C_{XX}^{-1}, \qquad
\mu_{Y\mid X=x} = U_{Y\mid X}\phi_X(x).
\]
A rigorous centered treatment replaces this naive identity by
\[
\mu_{Y\mid x}
=
\mu_Y + (C_{XX}^{\dagger}C_{XY})^{*}\,(\phi_X(x)-\mu_X),
\]
with Moore–Penrose pseudoinverse and explicit mean terms. This distinction matters: centered and uncentered CMEs are not interchangeable, and the corrected centered formula avoids the independence pathology of the naive expression [1912.00671][1605.09522].

A recurrent misconception is that CME is merely the formal inversion of \(C_{XX}\). In infinite dimensions, \(C_{XX}\) is compact and generally non-invertible, so pseudoinverses or regularization are intrinsic rather than incidental. A second misconception is that the pointwise formula alone defines the object. The measure-theoretic account instead treats CME first as a Bochner conditional expectation and only then recovers operator representations under additional range and regularity conditions [1912.00671][2002.03689].

## 2. Empirical estimation and the regression viewpoint

Given samples \(\{(x_i,y_i)\}_{i=1}^n\), define the feature matrices
\[
\Phi_X = [\phi_X(x_1),\dots,\phi_X(x_n)], \qquad
\Phi_Y = [\phi_Y(y_1),\dots,\phi_Y(y_n)],
\]
and Gram matrices \(K_{XX}=[k_X(x_i,x_j)]_{i,j=1}^n\), \(L_{YY}=[k_Y(y_i,y_j)]_{i,j=1}^n\). The regularized empirical conditional operator is
\[
\hat U_{Y\mid X} = \Phi_Y (K_{XX}+n\lambda I)^{-1}\Phi_X^{\top},
\]
equivalently
\[
\hat U_{Y\mid X} = \hat C_{YX}(\hat C_{XX}+\lambda I)^{-1},
\]
with centered versions obtained by inserting the centering matrix \(H=I_n-\frac1n 11^{\top}\). For a new \(x\),
\[
\hat\mu_{Y\mid x} = \Phi_Y (K_{XX}+n\lambda I)^{-1} k_X(x),
\qquad
k_X(x)=[k_X(x,x_1),\dots,k_X(x,x_n)]^{\top}.
\]
Hence, for \(g\in H_Y\),
\[
\mathbb{E}[g(Y)\mid X=x] \approx \langle g,\hat\mu_{Y\mid x}\rangle_{H_Y}
\approx \sum_{i=1}^n \alpha_i(x)\, g(y_i),
\]
where \(\alpha(x)=(K_{XX}+n\lambda I)^{-1}k_X(x)\) [1605.09522].

A central structural result is that the standard CME estimator is exactly the solution of a vector-valued regression problem. With operator-valued kernel
\[
\Gamma(x,x') = k_X(x,x')\,\mathrm{Id}_{H_Y},
\]
the estimator minimizes
\[
\min_{f\in H_{\Gamma}}
\frac1n\sum_{i=1}^n \|f(x_i)-\phi_Y(y_i)\|_{H_Y}^2
+
\lambda \|f\|_{H_{\Gamma}}^2,
\]
and the representer solution is
\[
f^{*}(x)=\Phi_Y (K_X+n\lambda I)^{-1} k_X(x).
\]
This equivalence supplies a loss-based interpretation of CME, permits standard model-selection procedures such as cross-validation, and leads to sparse estimators through a matrix Lasso formulation that penalizes a surrogate of the RKHS approximation error [1205.4656].

The regression perspective also clarifies what the estimator is optimizing when the conditional expectation operator is misspecified. In that setting, surrogate regression risk still controls the direct conditional-expectation risk, but exact coincidence requires representability conditions in the chosen vector-valued RKHS [1205.4656].

## 3. Conditional probabilistic calculus in RKHS

The operational significance of CME is that elementary rules of probabilistic calculus become linear operations on embeddings. The kernel sum rule takes the form
\[
\mu_X = U_{X\mid Y}\mu_Y,
\]
which is the RKHS analogue of the law of total expectation. The kernel product rule expresses the joint mean embedding through conditional operators and second-moment embeddings:
\[
\mu_{XY} = U_{X\mid Y}\mu_Y^{\otimes} = U_{Y\mid X}\mu_X^{\otimes},
\]
or, at operator level,
\[
C_{XY} = U_{X\mid Y}C_{YY} = U_{Y\mid X}C_{XX}.
\]
Kernel Bayes’ rule then defines a posterior embedding from prior embeddings \(\mu_Y^{\Pi}\) and \(C_{YY}^{\Pi}\):
\[
\mu_{Y\mid x}^{\Pi} = C_{YX}^{\Pi} (C_{XX}^{\Pi})^{-1}\phi_X(x),
\]
with a robust regularization
\[
(C_{XX}^{\Pi})^{-1}
\;\leadsto\;
\big((C_{XX}^{\Pi})^{2}+\tilde\lambda I\big)^{-1}C_{XX}^{\Pi}
\]
when \(C_{XX}^{\Pi}\) is not positive definite [1605.09522].

These identities explain why CME has been used for nonparametric probabilistic inference in graphical models, filtering in dynamical systems, and reinforcement learning. In each case, inference is phrased as manipulations of RKHS elements rather than explicit densities, which is especially useful for non-Gaussian continuous variables [1605.09522].

Closely related objects include Hilbert–Schmidt covariance operators and dependence measures such as HSIC, \(\|C_{YX}\|_{HS}^{2}\). In the conditional setting, the measure-theoretic theory yields conditional analogues of both maximum mean discrepancy and HSIC. Maximum conditional mean discrepancy compares conditional embeddings pointwise, while the Hilbert–Schmidt conditional independence criterion is based on the conditional joint embedding minus the tensor product of conditional marginals; under characteristic kernels, vanishing conditional discrepancy characterizes equality of conditional laws, and vanishing conditional HSIC characterizes conditional independence [2002.03689].

## 4. Existence, regularization, and statistical rates

At minimum, CME requires integrability of RKHS-valued feature maps. For marginal embeddings, \(\mathbb{E}[\sqrt{k(X,X)}]<\infty\) ensures existence; for covariance operators, \(\mathbb{E}[k(X,X)]<\infty\) and \(\mathbb{E}[l(Y,Y)]<\infty\) imply that \(C_{XX}\) and \(C_{YX}\) are Hilbert–Schmidt. Under the condition that \(\mathbb{E}[g(Y)\mid X=\cdot]\in H_X\) for all \(g\in H_Y\), one has the operator identity
\[
C_{XX}\,\mathbb{E}[g(Y)\mid X=\cdot] = C_{YX} g,
\]
which motivates the operator \(U_{Y\mid X}=C_{YX}C_{XX}^{-1}\) on the appropriate range. In practice, regularization is unavoidable because \(C_{XX}\) is compact and often nearly singular [1605.09522].

For empirical covariance operators, centered estimators satisfy
\[
\|\hat C_{YX}-C_{YX}\|_{HS}=O_p(n^{-1/2}).
\]
For Tikhonov-regularized CME, a standard pointwise rate is
\[
\|\hat\mu_{Y\mid x}-\mu_{Y\mid x}\|
=
O_p\big((n\lambda)^{-1/2}+\lambda^{1/2}\big),
\]
and under eigenvalue decay \(\gamma_m\le \beta m^{-b}\), the rate
\[
O_p\big(n^{-b/(4b+1)}\big)
\]
is achievable with an appropriate choice of \(\lambda\). Kernel Bayes’ rule posterior expectations also converge in probability, with rates depending on prior mean estimation accuracy [1605.09522].

The vector-valued regression formulation sharpens this picture. It yields minimax upper rates ranging from \(O(1/n)\) in favorable regimes to \(O((\log n/n)^{2/3})\) in harder infinite-dimensional regimes, together with lower bounds showing near-optimality up to logarithmic factors. These results are obtained under milder and more interpretable assumptions than earlier operator-smoothness conditions [1205.4656].

More recent analyses place CME in interpolation or Sobolev-type scales between \(H_X\) and \(L_2\). In the misspecified setting, where the target operator need not be Hilbert–Schmidt on the original input RKHS, one obtains adaptive convergence rates in Sobolev norms and, in some parameter regimes, uniform convergence in the output RKHS [2105.07446]. A complementary line of work introduces vector-valued interpolation spaces and proves optimal rates for regularized CME learning in the misspecified setting, including \(O(\log n/n)\) in favorable regimes without assuming \(H_Y\) to be finite-dimensional, as well as matching lower bounds [2208.01711].

Characteristic and universal kernels play a special role in identifiability. Characteristic kernels make the mean map injective, and universal kernels are characteristic on compact domains. Gaussian and Laplace kernels are characteristic on \(\mathbb{R}^{d}\), and Gaussian or Laplace kernels are universal on compact sets. At the same time, characteristic kernels are not strictly necessary for every downstream task; they are sufficient for uniqueness, but some predictive objectives can be solved without full injectivity [1605.09522].

## 5. Reinterpretations, computational variants, and recent extensions

One major development is the operator-free, measure-theoretic formulation of kernel conditional mean embeddings. In that approach, CME is defined directly as the Bochner conditional expectation \(\mathbb{E}[k_Y(\cdot,Y)\mid X]\), and the familiar regularized estimator is recovered from vector-valued kernel ridge regression rather than postulated as a population operator identity. The same framework naturally yields conditional versions of MMD and HSIC [2002.03689].

A second reinterpretation comes from the linear conditional expectation in Hilbert spaces. There, CME appears as the Bayes linear, or best affine, estimator in feature space. Under compatible range conditions, the regularized affine minimizer is
\[
\mu_Y + C_{YX}(C_{XX}+\lambda I)^{-1}(\phi_X(x)-\mu_X),
\]
and exactness follows under approximation assumptions labelled \(\mathrm{(B)}\) and \(\mathrm{(B^{*})}\). This yields an alternative justification of CME through Gaussian conditioning and affine Hilbert–Schmidt regularization [2008.12070].

Algorithmically, several directions address scalability and representation quality. A recursive estimator in a Bochner \(L_2\) space updates the conditional mean map by local averaging,
\[
\mu_{n+1}(x)
=
\big(1-a_{n+1}k_{n+1}(x,X_{n+1})\big)\mu_n(x)
+
a_{n+1}k_{n+1}(x,X_{n+1})\,\ell(\cdot,Y_{n+1}),
\]
and is shown to be weakly and strongly \(L_2\)-consistent on locally compact Polish spaces, including Euclidean spaces, Riemannian manifolds, and locally compact subsets of function spaces [2302.05955].

Neural parameterizations replace the classical inverse \((K_X+n\lambda I)^{-1}\) by end-to-end learned coefficients on output-kernel atoms. In Neural-Kernel CME,
\[
\hat\mu_{P(Y\mid X)}(x)=\sum_{a=1}^{M}\phi(\eta_a)\,f_a(x;\theta),
\]
and the per-sample RKHS loss is
\[
-2\sum_{a=1}^{M} k_{\mathcal Y}(y_i,\eta_a)w_a
+
\sum_{a,b=1}^{M} k_{\mathcal Y}(\eta_a,\eta_b) w_a w_b.
\]
This avoids the \(O(n^3)\) Gram inversion of classical CME, supports conditional density estimation through Gaussian density kernels, and leads naturally to a distributional reinforcement-learning objective based on MMD [2403.10859].

Other recent extensions optimize the kernel itself or compress conditional structure directly. Operator-theoretic kernel selection over convex sets of positive definite kernels uses spectral criteria to construct task-adapted feature representations for CME [2305.08100]. Conditional distribution compression introduces the Average Maximum Conditional Mean Discrepancy,
\[
\mathrm{AMCMD}
=
\sqrt{
\mathbb{E}_{x\sim P_{X^{*}}}
\big[
\|\mu_{Y\mid X=x}-\mu_{Y'\mid X'=x}\|_{H_l}^{2}
\big]
},
\]
and develops Average Conditional Kernel Herding and Average Conditional Kernel Inducing Points to compress labelled datasets while preserving conditional structure [2504.10139].

In dynamical systems, the CME operator coincides with the Koopman operator restricted to an RKHS. This identity motivates online sparse learning algorithms for the Koopman operator under trajectory-based sampling, with last-iterate guarantees under mixing and explicit control of compression error [2405.07432].

## 6. Applications across inference, causality, adaptation, and control

CME has become a general-purpose nonparametric inference primitive. In probabilistic graphical models it underlies kernel belief propagation, latent-tree methods, spectral hidden Markov models, and filtering in dynamical systems. In reinforcement learning it provides embedded transition models, RKHS Bellman operators, kernel value iteration, predictive state representations, and belief updates in partially observable settings through kernel Bayes’ rule [1605.09522].

In causal inference, CME supports conditional distributional treatment-effect analysis beyond the conditional average treatment effect. With a characteristic outcome kernel \(l\), the MMD-associated conditional distributional treatment effect is
\[
U_{\mathrm{MMD}}(x)
=
\|\mu_{Y_1\mid X=x}-\mu_{Y_0\mid X=x}\|_{H},
\]
and a conditional witness function
\[
w_x(y)
=
\mu_{Y_1\mid X=x}(y)-\mu_{Y_0\mid X=x}(y)
\]
localizes where treatment and control distributions differ. The same framework gives a kernel conditional discrepancy test for the null hypothesis \(P_{Y_0\mid X=x}=P_{Y_1\mid X=x}\) almost everywhere, and a U-statistic regression scheme for conditional variance, skewness, Gini’s mean difference, and other higher-order functionals [2102.08208].

More recent work extends this logic to counterfactual distributions directly. Conditional Counterfactual Mean Embeddings define
\[
\mu_{Y^{1}\mid V}(v)=\mathbb{E}[\phi(Y^{1})\mid V=v],
\]
identify it through a doubly robust pseudo-outcome,
\[
\xi(Z)
=
\frac{A}{\pi(X)}\big(\phi(Y)-\mu_{0}(X)\big)+\mu_{0}(X),
\]
and establish rates of the form
\[
\mathbb{E}\big[\|\hat\mu_{Y^{1}\mid V}(V)-\mu_{Y^{1}\mid V}(V)\|_{H_Y}^{2}\big]
\lesssim
R_{\hat\xi}^{2}(\hat\mu_{Y^{1}\mid V})
+
\min\{R_{\pi}^{2}(\hat\pi),R_{\mu_{0}}^{2}(\hat\mu_{0})\},
\]
which formalize double robustness at the level of conditional distribution embeddings [2602.04736].

In domain adaptation, CME ideas are often operationalized through class-conditional alignment rather than explicit operator inversion. In wearable human action recognition, one recent method aligns source and target class-conditional mean embeddings by minimizing a kernel-based class-wise conditional MMD,
\[
\mathcal{L}_{\mathrm{kCMMD}}
=
\sum_{c=1}^{C}
\Big[
\frac{1}{n_c(n_c-1)}\sum_{i\neq j} k(z_i^{s},z_j^{s})
+
\frac{1}{m_c(m_c-1)}\sum_{i\neq j} k(z_i^{t},z_j^{t})
-
\frac{2}{n_cm_c}\sum_{i,j} k(z_i^{s},z_j^{t})
\Big],
\]
with pseudo-labels stabilized by temporal ensembling and consistency regularization [2410.17489].

In robust control, CME embeds transition kernels and uses MMD balls around empirical conditional embeddings as ambiguity sets:
\[
\widehat{\mathcal M}_{m}^{\epsilon}(x,a)
=
\big\{
\mathbb{P}(\cdot\mid x,a):
\|\Psi(\mathbb{P})-\hat\psi_m(x,a)\|_{H_X}\le \epsilon
\big\}.
\]
The inner robust expectation then becomes the support function of an RKHS ball,
\[
\sup_{\mu\in \widehat{\mathcal M}_{m}^{\epsilon}(x,a)}
\int f'(x')\,\mu(dx')
=
\epsilon \|f'\|_{H_X}
+
\sum_{i=1}^{m}\beta_i(x,a)\, f'(x_i^{+}),
\]
which yields tractable distributionally robust Bellman updates. Under suitable compactness and continuity assumptions, the resulting finite-horizon min–max problem admits deterministic Markov optimal policies [2304.00644].

Across these uses, CME functions less as a single estimator than as a unifying representation: conditional laws become RKHS elements, inference becomes operator algebra, and conditional distribution learning interfaces naturally with regression, dependence testing, Bayesian updating, control, and modern neural architectures. This suggests that the enduring significance of conditional mean embedding lies in its role as a common Hilbert-space language for nonparametric conditional inference [1605.09522].

Source: https://www.emergentmind.com/topics/conditional-mean-embedding