fdars-core 0.40.0

Functional Data Analysis algorithms in Rust
Documentation

Functional Data Analysis (FDA)

Rust CI Crates.io Documentation codecov License: MIT

High-performance Functional Data Analysis tools implemented in Rust, with Python and R bindings.

Packages

Package Language Registry Folder Status
fdars-core Rust crates.io fdars-core/ Crates.io
pyfda Python GitHub sipemu/pyfda Python bindings
fdars R CRAN sipemu/fdars-r CRAN ⚠️ outdated

Features

Area Capabilities
Core Simulation (KL expansion, GP with 8 kernels), functional operations, smoothing (NW, local polynomial, k-NN), spline interpolation, basis representations (B-spline, Fourier, P-spline)
Descriptive 8 depth measures + streaming online depth, functional summary statistics (variance, std, covariance, depth-based median, trimmed mean), 12 distance metrics (Lp, DTW, elastic, semimetrics, KL), LRT outlier detection
Regression Scalar-on-function (FPC, kernel, logistic, robust), function-on-scalar (FOSR, 2D FOSR, FANOVA), FPCA, PLS, ridge, mixed effects; wavelet-domain regressors (wcr: PCR/PLS in wavelet space, wnet: elastic-net)
Classification LDA, QDA, k-NN, kernel, DD-classifier, conformal prediction sets; k-means, fuzzy c-means, GMM
Elastic Alignment SRSF/DP alignment, Karcher mean (1-D/N-D), TSRVF, Bayesian (pCN MCMC), closed curves, transfer alignment, partial matching, multi-resolution, generative models, geodesics, FPNS, lambda CV, peak persistence
Elastic Robust Karcher median, trimmed mean, SRVF outlier detection, elastic depth, shape CIs, diagnostics, warp statistics, phase box plots, shape analysis
Elastic Models Elastic FPCA (vertical/horizontal/joint), jfPCA fit/transform seam (jfpca_fit/JfpcaModel/.transform()), elastic regression, PCR, logistic, scalar-on-shape (ScoSh), changepoint detection, elastic clustering
SPM T²/SPE Phase I/II, EWMA, MEWMA, CUSUM, adaptive EWMA, FRCC, profile monitoring; bootstrap/KDE limits, ARL, partial-domain, elastic SPM, iterative Phase I, Western Electric/Nelson rules
Explainability PDP/ICE, SHAP, ALE, LIME, Sobol, Friedman H, anchors, counterfactuals, prototype/criticism; influence diagnostics, VIF, calibration (ECE, Brier), saliency maps; FpcPredictor trait; VEESA: model-agnostic permutation feature importance (elastic_pfi), principal-direction reconstruction (JfpcaModel::principal_directions), end-to-end veesa_pipeline
Inference Tolerance bands (FPCA, conformal, Degras, exponential, elastic), conformal prediction (split, Jackknife+, CV+), equivalence testing (TOST); inductive elastic conformal anomaly detection (elastic_conformal_anomaly, amplitude/phase/combined NonConformityScore)
Time Series Seasonal detection (FFT, ACF, Autoperiod, SAZED, Lomb-Scargle, SSA, matrix profile), detrending (polynomial, LOESS, STL); wavelet DWT (Haar + Daubechies db2–db10, multi-level Mallat pyramid via decompose/reconstruct)
Specialized Streaming depth (online O(log N)), irregular data (CSR, kernel estimation)
Autodiff Forward-mode differentiable core (Scalar trait + Dual<T> number); soft_dtw_distance_generic and FPCA score projection are differentiable via Dual<f64>; multi-input grad/jacobian API; gradient verified against closed-form and central finite differences

Installation

Rust (fdars-core)

[dependencies]
fdars-core = "0.40"

Or install from the repository:

[dependencies]
fdars-core = { git = "https://github.com/sipemu/fdars" }

Python (pyfda)

Python bindings are available via sipemu/pyfda:

pip install git+https://github.com/sipemu/pyfda

R (fdars)

⚠️ Note: The R package currently lags behind the Rust core and is outdated at the moment. For the latest capabilities, use fdars-core (Rust) or pyfda (Python).

install.packages("fdars")

# Development version from GitHub (requires Rust toolchain)
devtools::install_github("sipemu/fdars-r")

Feature Flags

  • parallel (default): Enable rayon-based parallel processing
  • linalg: Enable linear algebra features (faer, ridge regression) — requires Rust 1.84+
  • serde: Add Serialize/Deserialize to core types and enable JSON support
  • js: Enable WASM support with JS random number generation

For WASM builds, disable default features:

[dependencies]
fdars-core = { version = "0.40", default-features = false }

Data Layout

Functional data is represented using the FdMatrix type, a column-major matrix wrapping a flat Vec<f64> with safe (i, j) indexing and dimension tracking:

  • For n observations with m evaluation points: data[(i, j)] gives observation i at point j
  • Zero-copy column access via data.column(j), row gather via data.row(i)
  • nalgebra interop via to_dmatrix() / from_dmatrix() for SVD operations
  • 2D surfaces (n observations, m1 x m2 grid): stored as n x (m1*m2) matrices

Quick Start

use fdars_core::{FdMatrix, fdata, depth};

// Create sample functional data (3 observations, 10 points each)
let n = 3;
let m = 10;
let data: Vec<f64> = (0..(n * m)).map(|i| (i as f64).sin()).collect();
let mat = FdMatrix::from_column_major(data, n, m).unwrap();
let argvals: Vec<f64> = (0..m).map(|i| i as f64 / (m - 1) as f64).collect();

// Compute mean function
let mean = fdata::mean_1d(&mat);

// Compute Fraiman-Muniz depth
let depths = depth::fraiman_muniz_1d(&mat, &mat, true);

Examples

28 runnable examples in fdars-core/examples/:

# Example Topics
01 Simulation KL expansion, GP generation
02 Functional Operations Mean, derivatives, norms
03 Smoothing NW, local polynomial, k-NN
04 Basis Representation B-splines, Fourier, P-splines
05 Depth Measures 8 depth measures, outlier ranking
06 Distances Lp, DTW, elastic, semimetrics
07 Clustering K-means, fuzzy c-means
08 Regression FPCA, PLS
09 Outlier Detection LRT bootstrap
10 Seasonal Analysis FFT, Autoperiod, SAZED
11 Detrending Polynomial, LOESS, STL
12 Streaming Depth Online depth
13 Irregular Data CSR storage, kernel estimation
14 Complete Pipeline End-to-end workflow
15 Tolerance Bands FPCA, conformal, Degras SCB
16 Elastic Alignment SRSF, DP, Karcher mean
17 Equivalence Test Functional TOST
18 Landmark Registration Constrained alignment
19 TSRVF Transported SRVF
20 Scalar-on-Function * FPC linear, logistic, kernel
21 Function-on-Scalar * FOSR, FANOVA
22 GMM Clustering * GMM-EM, BIC/ICL
23 Classification * LDA, QDA, k-NN, DD
24 Mixed Effects * FAMM, REML
25 Explainability * SHAP, ALE, PDP, anchors
26 Elastic Analysis * Elastic FPCA, regression, PCR
27 SPM Phase I/II, EWMA, CUSUM, rules
28 Berkeley Growth Growth-curve case study: P-spline smoothing, GCV/AIC/BIC selection, 10-fold CV, PLS

* requires --features linalg

Run with cargo run -p fdars-core --example <name> (add --features linalg where marked).

Performance

With the parallel feature (enabled by default), computationally intensive operations use rayon for multi-core performance. The library also supports WASM targets with sequential execution.

Documentation

Guides (documentation/)

  • Getting Started — install, first program, running the examples
  • ArchitectureFdMatrix layout, module map, error model, parallelism
  • Configuration — Cargo feature flags, MSRV, build targets
  • Development — conventions, adding modules, local gates, CI
  • Testing — test layout, run commands, benchmarks, coverage

License

MIT