pub fn mean_2d(data: &[f64], n: usize, m: usize) -> Vec<f64>
Compute the mean function for 2D surfaces.
Data is stored as n x (m1*m2) matrix where each row is a flattened surface.