Skip to main content

Engine

Struct Engine 

Source
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>

Source

pub fn new(config: MatrixProfileConfig) -> Self

Create a new engine with the given configuration.

Source

pub fn compute(&self, ts: &[f64]) -> MatrixProfile

Compute the full matrix profile for a time series (batch STOMP).

Source

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.
Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn mpdist_pnorm( &self, ts_a: &[f64], ts_b: &[f64], p: f64, percentage: Option<f64>, ) -> f64

Compute MPdist using Minkowski p-norm distance.

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>

§

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>

§

impl<M> UnwindSafe for Engine<M>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.