Skip to main content

quantile_distribution_kernel

Function quantile_distribution_kernel 

Source
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,
) -> f64
Expand description

Kernel between two distributions defined via their quantile embeddings.

Computes a kernel value between distributions P and Q by:

  1. Embedding each as a vector of kernel-smoothed quantile values
  2. 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 P
  • samples_q - 1D samples from distribution Q
  • tau_levels - Quantile levels at which to compare
  • bandwidth - Smoothing bandwidth for quantile function (0 = no smoothing)
  • scalar_kernel - Kernel applied to pairs of quantile values
  • weighting - 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.