How to use the stumpy._calculate_squared_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_stump.py View on Github external
def test_calculate_squared_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
    )
    left = np.square(left)
    M_T, Σ_T = core.compute_mean_std(T, m)
    QT = core.sliding_dot_product(Q, T)
    μ_Q, σ_Q = core.compute_mean_std(Q, m)
    right = _calculate_squared_distance_profile(m, QT, μ_Q[0], σ_Q[0], M_T, Σ_T)
    npt.assert_almost_equal(left, right)
github TDAmeritrade / stumpy / stumpy / mstump.py View on Github external
else:
                    # Odd
                    QT_odd[i, j] = (
                        QT_even[i, j - 1]
                        - T[i, idx - 1] * T[i, j - 1]
                        + T[i, idx + m - 1] * T[i, j + m - 1]
                    )

            if idx % 2 == 0:
                QT_even[i, 0] = QT_first[i, idx]
                D[i] = _calculate_squared_distance_profile(
                    m, QT_even[i], μ_Q[i, idx], σ_Q[i, idx], M_T[i], Σ_T[i]
                )
            else:
                QT_odd[i, 0] = QT_first[i, idx]
                D[i] = _calculate_squared_distance_profile(
                    m, QT_odd[i], μ_Q[i, idx], σ_Q[i, idx], M_T[i], Σ_T[i]
                )

        zone_start = max(0, idx - excl_zone)
        zone_stop = min(k, idx + excl_zone)
        D[:, zone_start:zone_stop] = np.inf

        D = np.sqrt(D)

        # Column-wise sort
        for col in range(k):
            # row_idx[:, col] = np.argsort(D[:, col])
            # D[:, col] = D[row_idx[:, col], col]
            D[:, col] = np.sort(D[:, col])
        D_prime[:] = 0.0
        for i in range(d):