proj_grad_kde_polysph: Projected gradient of the polyspherical kernel density...

View source: R/RcppExports.R

proj_grad_kde_polysphR Documentation

Projected gradient of the polyspherical kernel density estimator

Description

Computes the projected gradient \mathsf{D}_{(p-1)}\hat{f}(\boldsymbol{x};\boldsymbol{h}) of the kernel density estimator \hat{f}(\boldsymbol{x};\boldsymbol{h}) on the polysphere \mathcal{S}^{d_1} \times \cdots \times \mathcal{S}^{d_r}, where p=\sum_{j=1}^r d_j+r is the dimension of the ambient space.

Usage

proj_grad_kde_polysph(x, X, d, h, weights = as.numeric(c()),
  wrt_unif = FALSE, normalized = TRUE, norm_x = FALSE, norm_X = FALSE,
  kernel = 1L, kernel_type = 1L, k = 10, proj_alt = TRUE,
  fix_u1 = TRUE, sparse = FALSE)

Arguments

x

a matrix of size c(nx, sum(d) + r) with the evaluation points.

X

a matrix of size c(n, sum(d) + r) with the sample.

d

vector of size r with dimensions.

h

vector of size r with bandwidths.

weights

weights for each observation. If provided, a vector of size n with the weights for multiplying each kernel. If not provided, set internally to rep(1 / n, n), which gives the standard estimator.

wrt_unif

flag to return a density with respect to the uniform measure. If FALSE (default), the density is with respect to the Lebesgue measure.

normalized

flag to compute the normalizing constant of the kernel and include it in the kernel density estimator. Defaults to TRUE.

norm_x, norm_X

ensure a normalization of the data? Defaults to FALSE.

kernel

kernel employed: 1 for von Mises–Fisher (default); 2 for Epanechnikov; 3 for softplus.

kernel_type

type of kernel employed: 1 for product kernel (default); 2 for spherically symmetric kernel.

k

softplus kernel parameter. Defaults to 10.0.

proj_alt

alternative projection. Defaults to TRUE.

fix_u1

ensure the u_1 vector is different from x? Prevents the Euler algorithm to "surf the ridge". Defaults to TRUE.

sparse

use a sparse eigendecomposition of the Hessian? Defaults to FALSE.

Value

A list with the following components:

eta

a matrix of size c(nx, sum(d) + r) with the projected gradient evaluated at x.

u1

a matrix of size c(nx, sum(d) + r) with the first non-null Hessian eigenvector evaluated at x.

lamb_norm

a matrix of size c(nx, sum(d) + r) with the Hessian eigenvalues (largest to smallest) evaluated at x.

Examples

# Simple check on (S^1)^2
n <- 3
d <- c(1, 1)
mu <- c(0, 1, 0, 1)
kappa <- c(5, 5)
h <- c(0.2, 0.2)
X <- r_vmf_polysph(n = n, d = d, mu = mu, kappa = kappa)
proj_grad_kde_polysph(x = X, X = X, d = d, h = h)

polykde documentation built on April 16, 2025, 1:11 a.m.