Skip to contents

Resolves a kernel_spec's bandwidth against data: when kernel$bandwidth is "median" (the default for RBF and Matern kernels) the median heuristic is computed from x; otherwise the fixed bandwidth is returned unchanged. This is the helper kernel_matrix() uses internally, exposed so that callers building kernel matrices by hand – for example a custom HSIC statistic via weighted_hsic_stat() – resolve the bandwidth exactly as the package does.

Usage

resolve_bandwidth(kernel, x)

Arguments

kernel

A kernel_spec object.

x

Numeric matrix (n by d) of data used to compute the median heuristic when kernel$bandwidth is "median".

Value

A kernel_spec with a resolved numeric bandwidth.

Examples

x <- matrix(rnorm(40), ncol = 2)
resolve_bandwidth(kernel_spec(), x)
#> Kernel specification:
#>   Type: rbf 
#>   Bandwidth: 1.914354