Skip to main content

Module pda

Module pda 

Source
Expand description

Linear differential operators and principal differential analysis.

This module provides two complementary tools for working with linear ordinary differential equations (ODEs) in functional data analysis:

  • Lfd: A linear differential operator that can be applied to a set of observed curves, forming Lx = D^m x + β_{m-1}(t)·D^{m-1}x + … + β₀(t)·x.
  • principal_differential_analysis: Estimates the coefficient functions of a linear ODE from a collection of observed solution curves.

§Relationship to the R fda package

The Lfd struct corresponds to the Lfd object in the R fda package (see https://rdrr.io/cran/fda/man/Lfd.html). The PDA estimator corresponds to pda.fd and recovers the weight functions β₀(t), …, β_{m-1}(t) of the order-m ODE by independent least squares at each grid point (see https://arxiv.org/abs/2406.18484).

§Examples

use fdars_core::pda::{Lfd, PdaResult, principal_differential_analysis};
use fdars_core::matrix::FdMatrix;
use std::f64::consts::PI;

// Build a harmonic-oscillator dataset: x_i(t) = cos(2π t)
let omega = 2.0 * PI;
let n_pts = 101;
let argvals: Vec<f64> = (0..n_pts).map(|i| i as f64 / (n_pts - 1) as f64).collect();
let n_curves = 5;
let mut data = FdMatrix::zeros(n_curves, n_pts);
for i in 0..n_curves {
    let a = (i + 1) as f64;
    for (j, &t) in argvals.iter().enumerate() {
        data[(i, j)] = a * (omega * t).cos();
    }
}

// Apply the identity-like Lfd (m=1, β₀ = 0) to verify shape invariance.
let lfd = Lfd { coefs: vec![vec![0.0]] };
let lx = lfd.apply(&data, &argvals).unwrap();
assert_eq!(lx.shape(), data.shape());

Structs§

Lfd
A linear differential operator of the form Lx(t) = D^m x(t) + β_{m-1}(t)·D^{m-1}x(t) + … + β₀(t)·x(t).
PdaResult
Result of principal_differential_analysis.

Functions§

principal_differential_analysis
Estimate the coefficient functions of a linear ODE from observed solution curves.