| stamp | R Documentation |
STAMP Computes the best so far Matrix Profile and Profile Index for Univariate Time Series.
STOMP is a faster implementation with the caveat that is not anytime as STAMP or SCRIMP.
SCRIMP is a faster implementation, like STOMP, but has the ability to return anytime results as STAMP.
MPX is by far the fastest implementation with the caveat that is not anytime as STAMP or SCRIMP.
stamp(
data,
window_size,
query = NULL,
exclusion_zone = 0.5,
s_size = 1,
n_workers = 1,
progress = TRUE
)
stomp(
data,
window_size,
query = NULL,
exclusion_zone = 0.5,
n_workers = 1,
progress = TRUE,
left_right_profile = FALSE
)
scrimp(
data,
window_size,
query = NULL,
exclusion_zone = 0.5,
s_size = 1,
pre_scrimp = 0.25,
n_workers = 1,
progress = TRUE
)
mpx(
data,
window_size,
query = NULL,
exclusion_zone = 0.5,
s_size = 1,
idxs = TRUE,
distance = c("euclidean", "pearson"),
n_workers = 1,
progress = TRUE,
na_strategy = c("monolithic", "segmented", "segmented_native"),
backend = c("cpu", "cuda")
)
mpx_stream_right(
new_data,
start_obj,
history = 0,
mp_time_constraint = 0,
progress = TRUE
)
mpx_stream_s_right(
data,
batch_size,
start_obj,
stats,
history = 0,
mp_time_constraint = 0,
progress = TRUE,
threshold = -1
)
data |
Required. Any 1-dimension series of numbers ( |
window_size |
Required. An integer defining the rolling window size. |
query |
Optional. Another 1-dimension series of numbers for an AB-join similarity.
Default is |
exclusion_zone |
A numeric. Defines the size of the area around the rolling window that will be ignored to avoid
trivial matches. Default is |
s_size |
A numeric. Used on anytime algorithms (stamp, scrimp, mpx) if only part of the computation is needed.
Default is |
n_workers |
An integer. The number of threads using for computing. Defaults to |
progress |
A logical. If |
left_right_profile |
( |
pre_scrimp |
A numeric. If not zero, pre_scrimp is computed, using a fraction of the data. Default is |
idxs |
( |
distance |
( |
na_strategy |
( |
backend |
( |
new_data |
a vector with the new data |
start_obj |
obj from another run |
history |
an |
mp_time_constraint |
time constraint for the mp update in terms of indices.
This parameter specifies how far back in the time series the algorithm will search
for the nearest neighbor. A value of 0 (default) means no constraint and the algorithm
will check the entire time series. Higher values limit the search to a window
that extends |
batch_size |
size of the new data |
stats |
obj with stats for mpx |
threshold |
Optional numeric threshold for distance comparison. Defaults to -1.0. |
The Matrix Profile, has the potential to revolutionize time series data mining because of its generality, versatility, simplicity and scalability. In particular it has implications for time series motif discovery, time series joins, shapelet discovery (classification), density estimation, semantic segmentation, visualization, rule discovery, clustering etc.
progress, it is really recommended to use it as feedback for long computations. It indeed adds some
(neglectable) overhead, but the benefit of knowing that your computer is still computing is much bigger than the
seconds you may lose in the final benchmark. Native multithreading uses RcppThread and is controlled by
n_workers. See matrixprofiler for guidance on parallel execution across processes and fork limitations.
The data and query parameters will be internally converted to a single vector using
as.numeric(), thus, bear in mind that a multidimensional matrix may not work as you expect, but most 1-dimensional
data types will work normally. If query is provided, expect the same pre-procesment done for data; in addition,
exclusion_zone will be ignored and set to 0. Both data and query doesn't need to have the same size and they
can be interchanged if both are provided. The difference will be in the returning object. AB-Join returns the Matrix
Profile 'A' and 'B' i.e., the distance between a rolling window from query to data and from data to query.
The anytime STAMP computes the Matrix Profile and Profile Index in such manner that it can be stopped before its complete calculation and return the best so far results allowing ultra-fast approximate solutions.
The STOMP uses a faster implementation to compute the Matrix Profile and Profile Index. It can be stopped earlier by
the user, but the result is not considered anytime, just incomplete. For a anytime algorithm, use stamp() or
scrimp().
The SCRIMP algorithm was the anytime solution for stomp. It is as fast as stomp but allows the user to cancel the computation and get an approximation of the final result. The exact SCRIMP phase shares the NA-aware diagonal recurrence used by MPX. In serial mode, pre-scrimp first seeds the profile from sampled distance profiles; the multithreaded implementation skips this pre-scrimp stage.
This algorithm was developed apart from the main Matrix Profile branch that relies on Fast Fourier Transform (FFT) at least in one part of the process. This algorithm doesn't use FFT at all and is several times faster. It also relies on Ogita's work for better precision computing mean and standard deviation (part of the process).
Inputs containing NA, NaN, Inf, or -Inf are automatically routed to the missing-data implementation. Fully
finite inputs continue to use the faster regular MPX implementation.
For MPX, values of s_size below 1 select a randomized subset of diagonals
and provide the intended anytime approximation. With s_size = 1, all
diagonals are processed in monotone order for better locality, so the final
result is exact but an interruption before completion can be less
representative than a randomized partial run. Use s_size < 1 when an
interrupted result should remain an anytime approximation.
The native segmented parallel AA implementation has an optional cache-tuning
setting for large NA-aware self-joins. This setting applies only when
na_strategy = "segmented_native" selects the native NA-aware parallel path.
When s_size = 1, MATRIXPROFILER_NATIVE_AA_BLOCK_SIZE controls the number of
profile windows in each rectangular internal block. Its default is 8192;
values from 1024 to 262144 are accepted and invalid values fall back to
the default. For example, set it for one shell invocation with
MATRIXPROFILER_NATIVE_AA_BLOCK_SIZE=16384 Rscript script.R, or set it in R
with Sys.setenv(MATRIXPROFILER_NATIVE_AA_BLOCK_SIZE = "16384") before
calling mpx(). Remove the override with
Sys.unsetenv("MATRIXPROFILER_NATIVE_AA_BLOCK_SIZE"). The setting is read
at call time, does not change the public mpx() API or its numerical
parameters, and is ignored for AB joins, finite inputs using regular MPX,
and sampled native runs with s_size < 1. It primarily trades cache
locality against task overhead; 8192 is a suitable starting point, while
larger values should only be selected after benchmarking a substantially
larger workload.
The internal C++ target matrix_profile_native_pairs_per_task (currently
100000000 pairwise window comparisons) controls the granularity of native
parallel AB tasks and sampled AA tasks. It is used only by the native
NA-aware parallel implementation. It is not an mpx() argument or an
environment variable; changing it requires a source change and recompiling
the package. It is normally left unchanged: increase it only when profiling
a very large workload shows excessive scheduling overhead, while retaining
several tasks per worker for load balancing. Neither setting affects the
regular MPX paths or the serial NA-aware implementations.
Returns a list with the matrix_profile, profile_index (if idxs is TRUE in mpx()), and some
information about the settings used to build it, like ez and partial when the algorithm is finished early.
Last updated on 2026-10-14 using R version 4.6.1.
Yeh CCM, Zhu Y, Ulanova L, Begum N, Ding Y, Dau HA, et al. Matrix profile I: All pairs similarity joins for time series: A unifying view that includes motifs, discords and shapelets. Proc - IEEE Int Conf Data Mining, ICDM. 2017;1317-22.
Zhu Y, Imamura m, Nikovski D, Keogh E. Matrix Profile VII: Time Series Chains: A New Primitive for Time Series Data Mining. Knowl Inf Syst. 2018 Jun 2;1-27.
Zhu Y, Zimmerman Z, Senobari NS, Yeh CM, Funning G. Matrix Profile II : Exploiting a Novel Algorithm and GPUs to Break the One Hundred Million Barrier for Time Series Motifs and Joins. Icdm. 2016 Jan 22;54(1):739-48.
Website: http://www.cs.ucr.edu/~eamonn/MatrixProfile.html
mass() for the underlying algorithm that finds best match of a query.
mpxab() for the forward and reverse join-similarity.
Other matrix profile computations:
mstomp()
mp <- stamp(motifs_discords_small, 50)
mp <- stomp(motifs_discords_small, 50)
mp <- scrimp(motifs_discords_small, 50)
mp <- mpx(motifs_discords_small, 50)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.