Spatial depth#
- DepthEucl.spatial(x: ndarray | None = None, mah_estimate: str = 'moment', mah_parMcd: float = 0.75, evaluate_dataset: bool = False) ndarray [source]
Calculates the spatial depth of points w.r.t. a multivariate data set.
- Arguments
- x: array-like or None, default=None
Matrix of objects (numerical vector as one object) whose depth is to be calculated; each row contains a d-variate point. Should have the same dimension as data.
- mah_estimatestr, {“moment”, “mcd”}, default=”moment”
A character string specifying which estimates to use when calculating the Mahalanobis depth; can be “‘moment’” or
'MCD'
, determining whether traditional moment or Minimum Covariance Determinant (MCD) estimates for mean and covariance are used.- mah_parMcdfloat, default=0.75
is the value of the argument alpha for the function covMcd; is used when mah.estimate =
'MCD'
.- evaluate_datasetbool, default=False
Determines if dataset loaded will be evaluated. Automatically sets x to dataset
- References
Serfling, R. (2002). A depth function and a scale curve based on spatial quantiles. In Dodge, Y. (Ed.), Statistical Data Analysis Based on the L1-Norm and Related Methods, Statisctics in Industry and Technology, Birkhäuser, Basel, 25–38.
- Examples
>>> import numpy as np >>> from depth.model import DepthEucl >>> mat1=[[1, 0, 0, 0, 0],[0, 2, 0, 0, 0],[0, 0, 3, 0, 0],[0, 0, 0, 2, 0],[0, 0, 0, 0, 1]] >>> mat2=[[1, 0, 0, 0, 0],[0, 1, 0, 0, 0],[0, 0, 1, 0, 0],[0, 0, 0, 1, 0],[0, 0, 0, 0, 1]] >>> x = np.random.multivariate_normal([1,1,1,1,1], mat2, 10) >>> data = np.random.multivariate_normal([0,0,0,0,0], mat1, 1000) >>> model=DepthEucl().load_dataset(data) >>> model.spatial(x, ) [0.22548919451212823, 0.14038895785356165, 0.2745517635029123, 0.35450156620496354, 0.42373722245348566, 0.34562025044812095, 0.3585616673301636, 0.16916309940691643, 0.573349631625784, 0.32017213635679687]