Transformed a 1-D continuous signal data and generated a range of transformations for the given bandwidth/scale. Now how to pick the best bandwidth or scale in the given range automatically?
Example: in the chart, the dark blue line is the original 1D continuous signal data. Every other curve is a transformation of that data for a range of bandwidths [10, 20, 30, 40, 50]. For this example, how to automatically pick the bandwidth which captures the variation in the curve best ?
Note: answers can be Python
specific or very general about how to calculate the "best" bandwidth.
import numpy
import matplotlib.pyplot as plt
from scipy.signal import ricker, cwt
data #numpy.ndarray
# data = ([11, 8, 8, 2, 2, 4, 4, 4, 4, 3, 3, 5, 5, 9, 12, 17, 19, 19, 20, 19, 19, 14, 12, 11, 9, 6, 4, 3, 3, 2, 2, 6, 9, 12, 16, 17, 19, 20, 20, 19, 17, 15, 13, 9, 7, 6, 5, 3, 2, 4], dtype=int64)
bandwidths = np.arange(10, 60, 10)
cwt_data = cwt(data, ricker, bandwidths) #transforms the data
plt.plot(cwt_speed.T, label='Transformed data')
plt.plot(speed, label='original data', linewidth=2)
plt.legend()
For this type of problem you can you use Welch's method scipy.signal.welch
to identify expected power of your wave carried by a given frequency.
The simple explanation for this method is that it bandpasses overlapping frequency ranges at several time duration and through successive averaging determines the signal-to-noise ratio represented at each frequency.
There a couple ways to use this analysis to select your band-pass for convolution.
I would recommend you look at the PSD and identify local maxima in the frequency spectra where the power deviates from the 1/f curve. The lower frequency ranges will usually be a better statistical fit (unless your signal carries an explicit encoded oscillatory signal), so the selecting the overall maximum would be affected by that.
For unencoded signals (neural data, historical trends, observed data, etc.), which it looks like you are working with, we are typically more concerned with where the 'bumps' on the curve occur, because those indicate at which frequency oscillatory drivers carry part of the signal. That way we can represent significant information instead of best fit due to randomness.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.