MCPcopy Index your code
hub / github.com/stumpy-dev/stumpy / maamp_multi_distance_profile

Function maamp_multi_distance_profile

stumpy/maamp.py:397–457  ·  view source on GitHub ↗

Multi-dimensional wrapper to compute the multi-dimensional non-normalized (i.e., without z-normalization) distance profile for a given query window within the times series or sequence that is denoted by the `query_idx` index. Parameters ---------- query_idx : int Th

(query_idx, T, m, include=None, discords=False, p=2.0)

Source from the content-addressed store, hash-verified

395
396
397def maamp_multi_distance_profile(query_idx, T, m, include=None, discords=False, p=2.0):
398 """
399 Multi-dimensional wrapper to compute the multi-dimensional non-normalized (i.e.,
400 without z-normalization) distance profile for a given query window within the
401 times series or sequence that is denoted by the `query_idx` index.
402
403 Parameters
404 ----------
405 query_idx : int
406 The window index to calculate the multi-dimensional distance profile
407
408 T : numpy.ndarray
409 The time series or sequence for which the multi-dimensional distance profile
410 will be returned
411
412 m : int
413 Window size
414
415 include : numpy.ndarray, default None
416 A list of (zero-based) indices corresponding to the dimensions in `T` that
417 must be included in the constrained multidimensional motif search.
418 For more information, see Section IV D in:
419
420 `DOI: 10.1109/ICDM.2017.66 \
421 <https://www.cs.ucr.edu/~eamonn/Motif_Discovery_ICDM.pdf>`__
422
423 discords : bool, default False
424 When set to `True`, this reverses the distance profile to favor discords rather
425 than motifs. Note that indices in `include` are still maintained and respected.
426
427 p : float, default 2.0
428 The p-norm to apply for computing the Minkowski distance. Minkowski distance is
429 typically used with `p` being 1 or 2, which correspond to the Manhattan distance
430 and the Euclidean distance, respectively.
431
432 Returns
433 -------
434 D : numpy.ndarray
435 Multi-dimensional distance profile for the window with index equal to
436 `query_idx`
437 """
438 T, T_subseq_isfinite = core.preprocess_non_normalized(T, m)
439
440 if T.ndim <= 1: # pragma: no cover
441 err = f"T is {T.ndim}-dimensional and must be at least 2-dimensional"
442 raise ValueError(f"{err}")
443
444 core.check_window_size(m, max_size=T.shape[1], n=T.shape[1])
445
446 if include is not None: # pragma: no cover
447 include = core._preprocess_include(include)
448
449 excl_zone = int(
450 np.ceil(m / config.STUMPY_EXCL_ZONE_DENOM)
451 ) # See Definition 3 and Figure 3
452
453 D = _maamp_multi_distance_profile(
454 query_idx, T, T, m, T_subseq_isfinite, p, include, discords, excl_zone

Callers 2

Calls 1

Tested by 2