Skip to main content

mean_1d

Function mean_1d 

Source
pub fn mean_1d(data: &FdMatrix) -> Vec<f64>
Expand description

Compute the mean function across all samples (1D).

§Arguments

  • data - Functional data matrix (n x m)

§Returns

Mean function values at each evaluation point

§Examples

use fdars_core::matrix::FdMatrix;
use fdars_core::fdata::mean_1d;

// 3 curves at 4 evaluation points
let data = FdMatrix::from_column_major(
    vec![1.0, 2.0, 3.0,  4.0, 5.0, 6.0,  7.0, 8.0, 9.0,  10.0, 11.0, 12.0],
    3, 4,
).unwrap();
let mean = mean_1d(&data);
assert_eq!(mean.len(), 4);
assert!((mean[0] - 2.0).abs() < 1e-10); // mean of [1, 2, 3]