@@ -18,29 +18,30 @@ def euclidean_distance_profile(
18
18
X : Union [np .ndarray , List ], q : np .ndarray , mask : np .ndarray
19
19
) -> np .ndarray :
20
20
"""
21
- Compute a distance profile using the squared Euclidean distance.
22
-
23
- It computes the distance profiles between the input time series and the query using
24
- the squared Euclidean distance. The distance between the query and a candidate is
25
- comptued using a dot product and a rolling sum to avoid recomputing parts of the
26
- operation.
27
-
28
- Parameters
29
- ----------
30
- X: np.ndarray, 3D array of shape (n_cases, n_channels, n_timepoints)
31
- The input samples. If X is an unquel length collection, expect a numba TypedList
32
- of 2D arrays of shape (n_channels, n_timepoints)
33
- q : np.ndarray, 2D array of shape (n_channels, query_length)
34
- The query used for similarity search.
35
- mask : np.ndarray, 3D array of shape (n_cases, n_channels, n_timepoints - query_length + 1) # noqa: E501
36
- Boolean mask of the shape of the distance profile indicating for which part
37
- of it the distance should be computed.
38
-
39
- Returns
40
- -------
41
- distance_profiles : np.ndarray
42
- 3D array of shape (n_cases, n_timepoints - query_length + 1)
43
- The distance profile between q and the input time series X.
21
+ Compute the distance profile using the squared Euclidean distance.
22
+
23
+ This method calculates the distance profiles between the input time series and the query
24
+ using the squared Euclidean distance. To optimize computation, it utilizes a dot product
25
+ and a rolling sum, reducing redundant calculations.
26
+
27
+ Parameters
28
+ ----------
29
+ X : np.ndarray or numba.typed.List
30
+ - If X is a NumPy array, it should have the shape ``(n_cases, n_channels, n_timepoints)``.
31
+ - If X contains sequences of unequal lengths, it should be a numba ``TypedList``
32
+ of 2D arrays, each with the shape ``(n_channels, n_timepoints)``.
33
+ q : np.ndarray
34
+ - A 2D array of shape ``(n_channels, query_length)`` representing the query used
35
+ for similarity search.
36
+ mask : np.ndarray
37
+ - A 3D boolean array of shape ``(n_cases, n_channels, n_timepoints - query_length + 1)``
38
+ that specifies which parts of the distance profile should be computed.
39
+
40
+ Returns
41
+ -------
42
+ distance_profiles : np.ndarray
43
+ - A 3D array of shape ``(n_cases, n_timepoints - query_length + 1)`` representing
44
+ the distance profiles between the query ``q`` and the input time series ``X``.
44
45
45
46
"""
46
47
distance_profiles = squared_distance_profile (X , q , mask )
@@ -60,37 +61,37 @@ def normalised_euclidean_distance_profile(
60
61
q_stds : np .ndarray ,
61
62
) -> np .ndarray :
62
63
"""
63
- Compute a distance profile in a brute force way .
64
+ Compute a distance profile using brute force.
64
65
65
66
It computes the distance profiles between the input time series and the query using
66
- the specified distance. The search is made in a brute force way without any
67
+ the specified distance. The search is performed in a brute- force manner without any
67
68
optimizations and can thus be slow.
68
69
69
70
Parameters
70
71
----------
71
- X: np.ndarray, 3D array of shape (n_cases, n_channels, n_timepoints)
72
- The input samples. If X is an unquel length collection, expect a numba TypedList
73
- of 2D arrays of shape (n_channels, n_timepoints)
74
- q : np.ndarray, 2D array of shape (n_channels, query_length)
72
+ X : np.ndarray, 3D array of shape `` (n_cases, n_channels, n_timepoints)``
73
+ The input samples. If `X` is an **unequal** length collection, expect a numba
74
+ ``TypedList`` of 2D arrays of shape `` (n_channels, n_timepoints)``.
75
+ q : np.ndarray, 2D array of shape `` (n_channels, query_length)``
75
76
The query used for similarity search.
76
- mask : np.ndarray, 3D array of shape (n_cases, n_channels, n_timepoints - query_length + 1) # noqa: E501
77
- Boolean mask of the shape of the distance profile indicating for which part
78
- of it the distance should be computed.
79
- X_means : np.ndarray, 3D array of shape (n_cases, n_channels, n_timepoints - query_length + 1) # noqa: E501
80
- Means of each subsequences of X of size query_length. Should be a numba
81
- TypedList if X is unequal length.
82
- X_stds : np.ndarray, 3D array of shape (n_cases, n_channels, n_timepoints - query_length + 1) # noqa: E501
83
- Stds of each subsequences of X of size query_length. Should be a numba
84
- TypedList if X is unequal length.
85
- q_means : np.ndarray, 1D array of shape (n_channels)
86
- Means of the query q
87
- q_stds : np.ndarray, 1D array of shape (n_channels)
77
+ mask : np.ndarray, 3D array of shape ``(n_cases, n_channels, n_timepoints - query_length + 1)``
78
+ Boolean mask indicating for which part of the distance profile the computation
79
+ should be performed.
80
+ X_means : np.ndarray, 3D array of shape ``(n_cases, n_channels, n_timepoints - query_length + 1)``
81
+ Means of each subsequence of ``X`` of size ``query_length``. Should be a numba
82
+ ``TypedList`` if ``X`` is of unequal length.
83
+ X_stds : np.ndarray, 3D array of shape ``(n_cases, n_channels, n_timepoints - query_length + 1)``
84
+ Standard deviations of each subsequence of ``X`` of size ``query_length``. Should be
85
+ a numba ``TypedList`` if ``X`` is of unequal length.
86
+ q_means : np.ndarray, 1D array of shape ``(n_channels,)``
87
+ Means of the query ``q``.
88
+ q_stds : np.ndarray, 1D array of shape ``(n_channels,)``
89
+ Standard deviations of the query ``q``.
88
90
89
91
Returns
90
92
-------
91
- distance_profiles : np.ndarray
92
- 3D array of shape (n_cases, n_timepoints - query_length + 1)
93
- The distance profile between q and the input time series X.
93
+ distance_profiles : np.ndarray, 3D array of shape ``(n_cases, n_timepoints - query_length + 1)``
94
+ The computed distance profile between ``q`` and the input time series ``X``.
94
95
95
96
"""
96
97
distance_profiles = normalised_squared_distance_profile (
0 commit comments