pub fn phase_boxplot(
gammas: &FdMatrix,
argvals: &[f64],
factor: f64,
) -> Result<PhaseBoxplot, FdarError>Expand description
Compute a phase box plot from a set of warping functions.
Ranks warps by modified band depth, identifies the median (deepest warp), builds the 50% central envelope, and flags outliers beyond the whisker fences. Whiskers are trimmed to the actual envelope of non-outlier warps.
§Arguments
gammas— Warping functions (n x m, one warp per row)argvals— Evaluation grid (length m)factor— Whisker extent as a multiple of the IQR envelope (e.g. 1.5)
§Errors
Returns FdarError::InvalidDimension if n < 3 or column count differs
from argvals. Returns FdarError::InvalidParameter if factor is not
positive.
§Examples
use fdars_core::matrix::FdMatrix;
use fdars_core::alignment::phase_boxplot;
let m = 20;
let argvals: Vec<f64> = (0..m).map(|i| i as f64 / (m - 1) as f64).collect();
// 5 slightly shifted warps
let mut data = vec![0.0; 5 * m];
for i in 0..5 {
let shift = 0.02 * (i as f64 - 2.0);
for j in 0..m {
let t = argvals[j];
data[j * 5 + i] = (t + shift * t * (1.0 - t)).clamp(0.0, 1.0);
}
}
let gammas = FdMatrix::from_column_major(data, 5, m).unwrap();
let bp = phase_boxplot(&gammas, &argvals, 1.5).unwrap();
assert_eq!(bp.median.len(), m);
assert!(bp.depths.iter().all(|&d| d >= 0.0));