View source: R/simplicial_depth.R
| simplicial_depth | R Documentation |
Computes the simplicial depth of one or more query points with respect
to a reference distribution estimated from data, using an adaptive
Monte Carlo approximation with parallel computation.
simplicial_depth(
x,
data,
tol = 0.05,
batch_size = 200L,
min_batches = 3L,
max_batches = 20L,
seed = 42L
)
x |
Numeric matrix of query points (m x d), or a numeric vector of length d for a single point. |
data |
Numeric matrix of reference data (n x d). Must have at least d+1 rows. |
tol |
Relative standard error tolerance for the adaptive stopping
rule. Sampling stops when the standard error of the depth estimate
drops below |
batch_size |
Number of random simplices sampled per batch. Default 200. |
min_batches |
Minimum number of batches before checking convergence. Default 3. |
max_batches |
Maximum number of batches regardless of convergence. Acts as a hard cap on computation time. Default 20. |
seed |
Integer random seed for reproducibility. Default 42. |
Simplicial depth is the probability that a random simplex formed by d+1 points drawn from the data contains the query point. It is a genuine multivariate generalization of the median with strong geometric intuition and no distributional assumptions.
The deepest point — the simplicial median — is a robust estimator of location that reduces to the univariate median when d=1.
Numeric vector of depth values in [0, 1], one per query point. Higher values indicate greater centrality.
Liu, R. Y. (1990). On a notion of data depth based on random simplices. Annals of Statistics, 18(1), 405–414.
Zuo, Y. & Serfling, R. (2000). General notions of statistical depth function. Annals of Statistics, 28(2), 461–482.
set.seed(42)
data <- matrix(rnorm(500), nrow = 100, ncol = 5)
x <- matrix(rnorm(25), nrow = 5, ncol = 5)
# Basic usage
simplicial_depth(x, data)
# Via compute_depth for full depth object
dd <- compute_depth(data, depth_fn = simplicial_depth)
median(dd)
outliers(dd)
plot(dd)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.