pub fn depth_based_median(data: &FdMatrix) -> Result<usize, FdarError>Expand description
Return the index of the deepest curve under the Fraiman-Muniz depth measure.
Computes self-depth scores (fraiman_muniz_1d(data, data, true)) and returns the
index i* of the curve with the maximum depth — the functional analog of the
depth-based median. The curve itself can be retrieved with data.row(i*) or
data[(i*, j)].
§Arguments
data- Functional data matrix (n x m), requires n >= 1.
§Returns
Index of the deepest curve.
§Errors
Returns FdarError::InvalidDimension if n == 0, or
FdarError::ComputationFailed if the depth vector is empty (should not occur with n >= 1).
§Examples
use fdars_core::matrix::FdMatrix;
use fdars_core::fdata::depth_based_median;
// 3 curves on 5 points; the middle curve (index 1) is most central
let data = FdMatrix::from_column_major(
vec![0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0],
3, 5,
).unwrap();
let idx = depth_based_median(&data).unwrap();
assert_eq!(idx, 1);