jsd_continuous: Estimate JSD for continuous variables

View source: R/jsd_continuous.R

jsd_continuousR Documentation

Estimate JSD for continuous variables

Description

Computes Jensen-Shannon divergence (JSD) between two numeric vectors using kernel density estimation (KDE) and numerical integration.

Usage

jsd_continuous(
  x,
  y,
  L = NULL,
  U = NULL,
  base = 2,
  bw = "nrd0",
  kernel = "gaussian",
  grid_n = 4096,
  qrange = c(0.001, 0.999),
  extend = 3,
  eps = 1e-12,
  renormalize = TRUE,
  na_rm = TRUE
)

Arguments

x

Numeric vector for group 1.

y

Numeric vector for group 2.

L

Optional lower integration bound.

U

Optional upper integration bound.

base

Logarithm base. Defaults to 2. Use 'exp(1)' for nats.

bw

Bandwidth passed to [stats::density()].

kernel

Kernel passed to [stats::density()].

grid_n

Number of grid points used for KDE.

qrange

Quantile range used when 'L' and 'U' are not supplied.

extend

Extension multiplier for the automatically chosen range.

eps

Small constant for numerical stability.

renormalize

Logical; renormalize estimated densities over the grid?

na_rm

Logical; remove missing values?

Value

An object of class '"jsd_estimate"'.


jsdtools documentation built on March 31, 2026, 1:06 a.m.