pub fn quantile_distribution_kernel(
samples_p: &[f64],
samples_q: &[f64],
tau_levels: &[f64],
bandwidth: f64,
scalar_kernel: impl Fn(f64, f64) -> f64,
weighting: &QuantileWeight,
) -> f64Expand description
Kernel between two distributions defined via their quantile embeddings.
Computes a kernel value between distributions P and Q by:
- Embedding each as a vector of kernel-smoothed quantile values
- Computing a kernel (e.g. RBF) between the embedding vectors
$$k_Q(P, Q) = \sum_{l=1}^L w_l \cdot k(Q_P(\tau_l),, Q_Q(\tau_l))$$
where Q_P(tau) is the smoothed quantile function of P at level tau,
and w_l are quantile-level weights.
This defines a positive-definite kernel on distributions when the base scalar kernel is positive definite.
§Arguments
samples_p- 1D samples from distribution Psamples_q- 1D samples from distribution Qtau_levels- Quantile levels at which to comparebandwidth- Smoothing bandwidth for quantile function (0 = no smoothing)scalar_kernel- Kernel applied to pairs of quantile valuesweighting- How to weight quantile levels
§Returns
Scalar kernel value between the two distributions.
§Panics
Panics if either sample set is empty or tau_levels is empty.