Find all matches of a query ``Q`` in a time series ``T`` The indices of subsequences whose distances to ``Q`` are less than or equal to ``max_distance``, sorted by distance (lowest to highest). Around each occurrence, an exclusion zone is applied before searching for the next.
(
Q,
T,
M_T=None,
Σ_T=None,
max_distance=None,
max_matches=None,
atol=1e-8,
query_idx=None,
normalize=True,
p=2.0,
T_subseq_isfinite=None,
T_subseq_isconstant=None,
Q_subseq_isconstant=None,
)
| 402 | replace={"M_T": "T_subseq_isfinite", "Σ_T": None}, |
| 403 | ) |
| 404 | def match( |
| 405 | Q, |
| 406 | T, |
| 407 | M_T=None, |
| 408 | Σ_T=None, |
| 409 | max_distance=None, |
| 410 | max_matches=None, |
| 411 | atol=1e-8, |
| 412 | query_idx=None, |
| 413 | normalize=True, |
| 414 | p=2.0, |
| 415 | T_subseq_isfinite=None, |
| 416 | T_subseq_isconstant=None, |
| 417 | Q_subseq_isconstant=None, |
| 418 | ): |
| 419 | """ |
| 420 | Find all matches of a query ``Q`` in a time series ``T`` |
| 421 | |
| 422 | The indices of subsequences whose distances to ``Q`` are less than or equal to |
| 423 | ``max_distance``, sorted by distance (lowest to highest). Around each occurrence, an |
| 424 | exclusion zone is applied before searching for the next. |
| 425 | |
| 426 | Parameters |
| 427 | ---------- |
| 428 | Q : numpy.ndarray |
| 429 | The query sequence. ``Q`` does not have to be a subsequence of ``T``. |
| 430 | |
| 431 | T : numpy.ndarray |
| 432 | The time series of interest. |
| 433 | |
| 434 | M_T : numpy.ndarray, default None |
| 435 | Sliding mean of time series, ``T``. |
| 436 | |
| 437 | Σ_T : numpy.ndarray, default None |
| 438 | Sliding standard deviation of time series, ``T``. |
| 439 | |
| 440 | max_distance : float or function, default None |
| 441 | Maximum distance between ``Q`` and a subsequence, ``S``, for ``S`` to be |
| 442 | considered a match. If ``max_distance`` is a function, |
| 443 | then it must be a function that accepts a single parameter, ``D``, in its |
| 444 | function signature, which is the distance profile between ``Q`` and ``T`` (a |
| 445 | 1D numpy array of size ``n - m + 1``). If ``None``, this defaults to |
| 446 | ``np.nanmax([np.nanmean(D) - 2 * np.nanstd(D), np.nanmin(D)])`` (i.e. at |
| 447 | least the closest match will be returned). |
| 448 | |
| 449 | max_matches : int, default None |
| 450 | The maximum amount of similar occurrences to be returned. The resulting |
| 451 | occurrences are sorted by distance, so a value of ``10`` means that the |
| 452 | indices of the most similar ``10`` subsequences is returned. If ``None``, then |
| 453 | all occurrences are returned. |
| 454 | |
| 455 | atol : float, default 1e-8 |
| 456 | The absolute tolerance parameter. This value will be added to ``max_distance`` |
| 457 | when comparing distances between subsequences. |
| 458 | |
| 459 | query_idx : int, default None |
| 460 | This is the index position along the time series, ``T``, where the query |
| 461 | subsequence, ``Q``, is located. ``query_idx`` should only be used when the |
no outgoing calls