dot-spatial_depth_cpp: Spatial Depth

.spatial_depth_cppR Documentation

Spatial Depth

Description

Computes the spatial depth of one or more query points with respect to a reference distribution estimated from data.

Usage

.spatial_depth_cpp(x, data)

Arguments

x

Numeric matrix of query points (m x d), or a numeric vector of length d for a single query point.

data

Numeric matrix of reference data (n x d).

Details

Spatial depth is defined as:

SD(x, F) = 1 - \left\| E\left[ \frac{x - X}{\|x - X\|} \right] \right\|

where the expectation is over X \sim F. It is estimated by the sample mean of unit vectors pointing from each data point toward x.

Unlike other depth functions in this package, spatial depth has a closed-form sample estimate and requires no Monte Carlo approximation. This makes it extremely fast even at large n and d.

Spatial depth is not affine invariant but is orthogonally invariant, and has been found to work well in high dimensions where affine invariant methods can be computationally prohibitive.

Value

Numeric vector of depth values in [0, 1], one per query point. A value of 1 indicates perfect centrality (the spatial median). Values decrease toward 0 as points move away from the center.

References

Vardi, Y. & Zhang, C.-H. (2000). The multivariate L1-median and associated data depth. Proceedings of the National Academy of Sciences, 97(4), 1423–1426.

Serfling, R. (2006). Depth functions in nonparametric multivariate inference. DIMACS Series in Discrete Mathematics, 72, 1–16.


depthR documentation built on June 26, 2026, 5:07 p.m.