-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Description:
In the current implementation of the savitskyGolayFilter function, the Savitzky-Golay filter is applied in a sequential manner, where each updated value depends on previously updated values. This contradicts the standard approach of applying the Savitzky-Golay filter, where each value should be computed based on the original unmodified data.
For example, in the function applyFilterOverAxis, when updating sequence[idx], it uses sequence[idx-1], which may have already been updated in a previous step. This can lead to incorrect results, as the filter should always operate on the original data rather than the updated sequence.
Expected Behavior:
The filter should calculate new values based on the original sequence without using previously updated values. A possible solution is to store the filtered results in a temporary array and apply them to the sequence only after all points have been filtered.
Affected Code:
sequence(idx) = applyFilter({
sequence(idx - 4),
sequence(idx - 3),
sequence(idx - 2),
sequence(idx - 1),
sequence(idx),
sequence(idx + 1),
sequence(idx + 2),
sequence(idx + 3),
sequence(idx + 4)
});Suggested Fix:
Consider storing the filtered values in a separate temporary array to ensure each value is calculated using the original sequence data, and only update the sequence once all values are computed.