| .mahalanobis_depth_cpp | R Documentation |
Computes the Mahalanobis depth of one or more query points with respect
to a reference distribution estimated from data.
.mahalanobis_depth_cpp(x, data, mu = NULL, sigma = NULL)
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). Used to estimate the mean and covariance. |
mu |
Optional numeric vector of length d. If supplied, overrides the
mean estimated from |
sigma |
Optional numeric matrix (d x d). If supplied, overrides the
covariance estimated from |
Mahalanobis depth is defined as
D(x, F) = \frac{1}{1 + (x - \mu)^\top \Sigma^{-1} (x - \mu)}
where \mu and \Sigma are the mean vector and covariance matrix
of F, estimated from data.
Note: The deepest point under this depth function is the mean vector, not
a robust generalization of the median. Mahalanobis depth is included here
as a computationally trivial baseline and for comparison purposes.
For a genuine depth function, prefer simplicial_depth or
tukey_depth.
Numeric vector of depth values in (0, 1], one per query point. A value of 1 indicates the query point coincides with the center (mean). Values decrease toward 0 as points move away from the center.
set.seed(42)
data <- matrix(rnorm(200), nrow = 100, ncol = 2)
x <- matrix(c(0, 0, 3, 3), nrow = 2, byrow = TRUE)
mahalanobis_depth(x, data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.