pub struct Engine<M: DistanceMetric> { /* private fields */ }Expand description
High-level facade for matrix profile computation, generic over distance metric.
§Examples
use motif_rs::{EuclideanEngine, MatrixProfileConfig};
let ts = vec![1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0];
let engine = EuclideanEngine::new(MatrixProfileConfig::new(4));
let mp = engine.compute(&ts);
assert_eq!(mp.profile.len(), ts.len() - 4 + 1);Implementations§
Source§impl<M: DistanceMetric> Engine<M>
impl<M: DistanceMetric> Engine<M>
Sourcepub fn new(config: MatrixProfileConfig) -> Self
pub fn new(config: MatrixProfileConfig) -> Self
Create a new engine with the given configuration.
Sourcepub fn compute(&self, ts: &[f64]) -> MatrixProfile
pub fn compute(&self, ts: &[f64]) -> MatrixProfile
Compute the full matrix profile for a time series (batch STOMP).
Sourcepub fn streaming(&self, initial_ts: &[f64], egress: bool) -> Stampi<M>
pub fn streaming(&self, initial_ts: &[f64], egress: bool) -> Stampi<M>
Create a streaming matrix profile from an initial time series.
egress=false: grow mode — time series extends unboundedly.egress=true: egress mode — fixed-size sliding window.
Sourcepub fn ab_join(&self, ts_a: &[f64], ts_b: &[f64]) -> (JoinProfile, JoinProfile)
pub fn ab_join(&self, ts_a: &[f64], ts_b: &[f64]) -> (JoinProfile, JoinProfile)
Compute the AB-join between two time series.
Returns two JoinProfiles: one for each series against the other.
Sourcepub fn compute_topk(&self, ts: &[f64], k: usize) -> TopKMatrixProfile
pub fn compute_topk(&self, ts: &[f64], k: usize) -> TopKMatrixProfile
Compute the top-k matrix profile for a time series.
Stores the k nearest neighbors for each subsequence, rather than just the best one.
Sourcepub fn snippets(&self, ts: &[f64], k: usize) -> SnippetsResult
pub fn snippets(&self, ts: &[f64], k: usize) -> SnippetsResult
Extract k representative snippets that best summarize the time series.
Uses z-normalized Euclidean distance profiles regardless of the engine’s metric.
Sourcepub fn mpdist(&self, ts_a: &[f64], ts_b: &[f64], percentage: Option<f64>) -> f64
pub fn mpdist(&self, ts_a: &[f64], ts_b: &[f64], percentage: Option<f64>) -> f64
Compute MPdist: a scalar distance between two time series.
Based on the k-th percentile of the concatenated AB-join profiles.
Sourcepub fn scrump(&self, ts: &[f64], percentage: f64) -> MatrixProfile
pub fn scrump(&self, ts: &[f64], percentage: f64) -> MatrixProfile
Compute an approximate matrix profile using SCRUMP/PreSCRIMP.
percentage in (0.0, 1.0] controls the fraction of diagonals sampled.
At 1.0, delegates to exact STOMP.
Sourcepub fn ostinato(&self, ts_list: &[&[f64]]) -> ConsensusMotif
pub fn ostinato(&self, ts_list: &[&[f64]]) -> ConsensusMotif
Find the consensus motif across multiple time series.
Returns the subsequence (from any series) whose maximum nearest-neighbor distance to all other series is minimized.
Sourcepub fn stimp(
&self,
ts: &[f64],
min_m: usize,
max_m: usize,
step: Option<usize>,
percentage: Option<f64>,
) -> PanMatrixProfile
pub fn stimp( &self, ts: &[f64], min_m: usize, max_m: usize, step: Option<usize>, percentage: Option<f64>, ) -> PanMatrixProfile
Compute the pan matrix profile across a range of window sizes.
Profiles are normalized by 1/sqrt(2*m) for cross-window comparability.
Sourcepub fn compute_pnorm(&self, ts: &[f64], p: f64) -> MatrixProfile
pub fn compute_pnorm(&self, ts: &[f64], p: f64) -> MatrixProfile
Compute the matrix profile using Minkowski p-norm distance.
For p == 2.0, delegates to the optimized AAMP path.
For other values of p, uses a diagonal recurrence.
This is AAMP-only (non-normalized); the engine’s metric type M is ignored.
Sourcepub fn ab_join_pnorm(
&self,
ts_a: &[f64],
ts_b: &[f64],
p: f64,
) -> (JoinProfile, JoinProfile)
pub fn ab_join_pnorm( &self, ts_a: &[f64], ts_b: &[f64], p: f64, ) -> (JoinProfile, JoinProfile)
Compute the AB-join between two time series using Minkowski p-norm distance.
Returns two JoinProfiles, one for each series.
This is AAMP-only (non-normalized); the engine’s metric type M is ignored.
Auto Trait Implementations§
impl<M> Freeze for Engine<M>where
PhantomData<M>: Freeze,
impl<M> RefUnwindSafe for Engine<M>where
PhantomData<M>: RefUnwindSafe,
impl<M> Send for Engine<M>where
PhantomData<M>: Send,
impl<M> Sync for Engine<M>where
PhantomData<M>: Sync,
impl<M> Unpin for Engine<M>where
PhantomData<M>: Unpin,
impl<M> UnsafeUnpin for Engine<M>where
PhantomData<M>: UnsafeUnpin,
impl<M> UnwindSafe for Engine<M>where
PhantomData<M>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more