How to use the stumpy.core.calculate_distance_profile function in stumpy

To help you get started, we’ve selected a few stumpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TDAmeritrade / stumpy / tests / test_core.py View on Github external
def test_calculate_distance_profile(Q, T):
    m = Q.shape[0]
    left = np.linalg.norm(
        core.z_norm(core.rolling_window(T, m), 1) - core.z_norm(Q), axis=1
    )
    QT = core.sliding_dot_product(Q, T)
    μ_Q, σ_Q = core.compute_mean_std(Q, m)
    M_T, Σ_T = core.compute_mean_std(T, m)
    right = core.calculate_distance_profile(m, QT, μ_Q, σ_Q, M_T, Σ_T)
    npt.assert_almost_equal(left, right)
github TDAmeritrade / stumpy / stumpy / stomp.py View on Github external
# Handle first subsequence, add exclusionary zone
    if ignore_trivial:
        P, I = stamp.mass(T_B[:m], T_A, M_T, Σ_T, 0, excl_zone)
        PR, IR = stamp.mass(T_B[:m], T_A, M_T, Σ_T, 0, excl_zone, right=True)
    else:
        P, I = stamp.mass(T_B[:m], T_A, M_T, Σ_T)
        IR = -1  # No left and right matrix profile available
    out[0] = P, I, -1, IR

    k = T_A.shape[0] - m + 1
    for i in range(1, l):
        QT[1:] = (
            QT[: k - 1] - T_B[i - 1] * T_A[: k - 1] + T_B[i - 1 + m] * T_A[-(k - 1) :]
        )
        QT[0] = QT_first[i]
        D = core.calculate_distance_profile(m, QT, μ_Q[i], σ_Q[i], M_T, Σ_T)
        if ignore_trivial:
            zone_start = max(0, i - excl_zone)
            zone_stop = min(k, i + excl_zone)
            D[zone_start:zone_stop] = np.inf
        I = np.argmin(D)
        P = D[I]

        # Get left and right matrix profiles for self-joins
        if ignore_trivial and i > 0:
            IL = np.argmin(D[:i])
            if zone_start <= IL < zone_stop:  # pragma: no cover
                IL = -1
        else:
            IL = -1

        if ignore_trivial and i + 1 < D.shape[0]: