Skip to main content

fdars_core/
lib.rs

1//! # fdars-core
2//!
3//! Core algorithms for Functional Data Analysis in Rust.
4//!
5//! This crate provides pure Rust implementations of various FDA methods including:
6//! - Functional data operations (mean, derivatives, norms)
7//! - Depth measures (Fraiman-Muniz, modal, band, random projection, etc.)
8//! - Distance metrics (Lp, Hausdorff, DTW, Fourier, etc.)
9//! - Basis representations (B-splines, P-splines, Fourier)
10//! - Clustering (k-means, fuzzy c-means)
11//! - Smoothing (Nadaraya-Watson, local linear/polynomial regression)
12//! - Outlier detection
13//! - Regression (PCA, PLS, ridge)
14//! - Seasonal analysis (period estimation, peak detection, seasonal strength)
15//! - Detrending and decomposition for non-stationary data
16//!
17//! ## Data Layout
18//!
19//! Functional data is represented using the [`FdMatrix`] type, a column-major matrix
20//! wrapping a flat `Vec<f64>` with safe `(i, j)` indexing and dimension tracking:
21//! - For n observations with m evaluation points: `data[(i, j)]` gives observation i at point j
22//! - 2D surfaces (n observations, m1 x m2 grid): stored as n x (m1*m2) matrices
23//! - Zero-copy column access via `data.column(j)`, row gather via `data.row(i)`
24//! - nalgebra interop via `to_dmatrix()` / `from_dmatrix()` for SVD operations
25
26#![allow(clippy::needless_range_loop)]
27#![allow(clippy::too_many_arguments)]
28#![allow(clippy::type_complexity)]
29
30pub mod matrix;
31pub mod parallel;
32
33pub mod alignment;
34pub mod basis;
35pub mod clustering;
36pub mod depth;
37pub mod detrend;
38pub mod fdata;
39pub mod helpers;
40pub mod irreg_fdata;
41pub mod metric;
42pub mod outliers;
43pub mod regression;
44pub mod seasonal;
45pub mod simulation;
46pub mod smoothing;
47pub mod streaming_depth;
48pub mod tolerance;
49pub mod utility;
50
51// Re-export matrix type
52pub use matrix::FdMatrix;
53
54// Re-export alignment types and functions
55pub use alignment::{
56    align_to_target, compose_warps, elastic_align_pair, elastic_cross_distance_matrix,
57    elastic_distance, elastic_self_distance_matrix, karcher_mean, reparameterize_curve,
58    srsf_inverse, srsf_transform, AlignmentResult, AlignmentSetResult, KarcherMeanResult,
59};
60
61// Re-export commonly used items
62pub use helpers::{
63    extract_curves, l2_distance, simpsons_weights, simpsons_weights_2d, DEFAULT_CONVERGENCE_TOL,
64    NUMERICAL_EPS,
65};
66
67// Re-export seasonal analysis types
68pub use seasonal::{
69    autoperiod, autoperiod_fdata, cfd_autoperiod, cfd_autoperiod_fdata, hilbert_transform, sazed,
70    sazed_fdata, AutoperiodCandidate, AutoperiodResult, CfdAutoperiodResult, ChangeDetectionResult,
71    ChangePoint, ChangeType, DetectedPeriod, InstantaneousPeriod, Peak, PeakDetectionResult,
72    PeriodEstimate, SazedComponents, SazedResult, StrengthMethod,
73};
74
75// Re-export detrending types
76pub use detrend::{DecomposeResult, TrendResult};
77
78// Re-export simulation types
79pub use simulation::{EFunType, EValType};
80
81// Re-export irregular fdata types
82pub use irreg_fdata::{IrregFdata, KernelType};
83
84// Re-export tolerance band types
85pub use tolerance::{
86    conformal_prediction_band, elastic_tolerance_band, equivalence_test,
87    equivalence_test_one_sample, exponential_family_tolerance_band, fpca_tolerance_band,
88    scb_mean_degras, BandType, EquivalenceBootstrap, EquivalenceTestResult, ExponentialFamily,
89    MultiplierDistribution, NonConformityScore, ToleranceBand,
90};
91
92// Re-export streaming depth types
93pub use streaming_depth::{
94    FullReferenceState, RollingReference, SortedReferenceState, StreamingBd, StreamingDepth,
95    StreamingFraimanMuniz, StreamingMbd,
96};