how to perform wavelet transform on time series speed signal
I have time vs velocity data. This should be used as my time series speed signal on which i have to perform continuous wavelet transform using matlab (wavelet toolbox). But I am not able to incorporate the time component. I am importing signal from workspace which is a nx1 array(velocity). Any clarification on how to incorporate time vs speed as my signal will be great. Thanks in advance...
See also questions close to this topic
Is there a faster way to compute element wise exponentials of a matrix in Matlab?
I am profiling my code and this one line seems to be a bottleneck. The idea is to create a spatial correlation matrix of n observations of a given dimension, based upon a theta vector of the same dimension--which contains dimensional hyperparameters to be fit.
In my overall code this spatial correlation function is called thousands of times (per iteration) while computing a likelihood function in order to optimize my theta parameters. The number of observations grows by one in each iteration of the overall code, and the theta parameters must be refit each iteration. So you can see how this line of code becomes crucial as the algorithm progresses.
I think that the slowest line, i.e.,
R = exp(sum(bsxfun(@times, -abs(D_X).^corr_model,reshape(theta,[1 1 d])),3));takes the most time to compute the final element-wise exponential across the resulting n by n matrix (the n by n matrix is yielded after summing over the 3 dimension of the distance matrix). But there is a lot going on in this line, so I am unsure if this is the most critical aspect to the overall performance.
Thanks for any insight you may have!
I have already replaced a
repmatcommand with a
bsxfun, to multiply the given thetas across the dimensional distance matrix
D_X, which sped up the code notably. However, nesting a second
bsxfunto execute the squaring of distances i.e., to replace
abs(D_X).^corr_model, made the code run slower.
n = 500; dimension = 20; D_X = repmat(rand(n),[1 1 dimension]); theta = rand(dimension, 1); corr_model = 2; R = corr(corr_model,theta, D_X); function R = corr(corr_model,theta,D_X) % calculate the correlation matrix for the modified nugget effect model % corr_model - the correlation model used for the spatial correlation % corr_model = 2: gaussian correlation function % theta - vector of hyperparameters % D_X - the distance matrix for the input locations d = size(theta,1); switch corr_model case 2 %Gaussian correlation function R = exp(sum(bsxfun(@times, -abs(D_X).^corr_model,reshape(theta,[1 1 d])),3)); end end
pinv(H) is not equal to pinv(H'*H)*H'
I'm testing the
y = SinC(x)function with single hidden layer feedforward neural networks (SLFNs) with 20 neurons.
With a SLFN, in the output layer, the output weight(OW) can be described by
OW = pinv(H)*T
after adding regularized parameter
OW = pinv(I/gamma+H'*H)*H'*T
gamma -> Inf, pinv(H'*H)*H'*T == pinv(H)*T, also pinv(H'*H)*H' == pinv(H).
But when I try to calculate
pinv(H), I find a huge difference between these two when neurons number is over 5 (under 5, they are equal or almost the same).
For example, when
cond(H) = 21137561386980.3,
rank(H) = 10,
H = [0.736251410036783 0.499731137079796 0.450233920602169 0.296610970576716 0.369359425954153 0.505556211442208 0.502934880027889 0.364904559142718 0.253349959726753 0.298697900877265; 0.724064281864009 0.521667364351399 0.435944895257239 0.337878535128756 0.364906002569385 0.496504064726699 0.492798607017131 0.390656915261343 0.289981152837390 0.307212326718916; 0.711534656474153 0.543520341487420 0.421761457948049 0.381771374416867 0.360475582262355 0.487454209236671 0.482668250979627 0.417033287703137 0.329570921359082 0.315860145366824; 0.698672860220896 0.565207057974387 0.407705930918082 0.427683127210120 0.356068794706095 0.478412571446765 0.472552121296395 0.443893207685379 0.371735862991355 0.324637323886021; 0.685491077062637 0.586647027111176 0.393799811411985 0.474875155650945 0.351686254239637 0.469385056318048 0.462458480695760 0.471085139463084 0.415948455902421 0.333539494486324; 0.672003357663056 0.607763454504209 0.380063647372632 0.522520267708374 0.347328559602877 0.460377531907542 0.452395518357816 0.498449772544129 0.461556360076788 0.342561958147251; 0.658225608290477 0.628484290731116 0.366516925684188 0.569759064961507 0.342996293691614 0.451395814182317 0.442371323528726 0.525823695636816 0.507817005881821 0.351699689941632; 0.644175558300583 0.648743139215935 0.353177974096445 0.615761051907079 0.338690023332811 0.442445652121229 0.432393859824045 0.553043275759248 0.553944175102542 0.360947346089454; 0.629872705346690 0.668479997764613 0.340063877672496 0.659781468051379 0.334410299080102 0.433532713184646 0.422470940392161 0.579948548513999 0.599160649563718 0.370299272759337; 0.615338237874436 0.687641820315375 0.327190410302607 0.701205860709835 0.330157655029498 0.424662569229062 0.412610204098877 0.606386924575225 0.642749594844498 0.379749516620049]; T=[-0.806458764562879 -0.251682808380338 -0.834815868451399 -0.750626822371170 0.877733363571576 1 -0.626938984683970 -0.767558933097629 -0.921811074815239 -1]';
There is a huge difference between
pinv(H'*H)*H*T = [-4803.39093243484 3567.08623820149 668.037919243849 5975.10699147077 1709.31211566970 -1328.53407325092 -1844.57938928594 -22511.9388736373 -2377.63048959478 31688.5125271114]'; pinv(H)*T = [-19780274164.6438 -3619388884.32672 -76363206688.3469 16455234.9229156 -135982025652.153 -93890161354.8417 283696409214.039 193801203.735488 -18829106.6110445 19064848675.0189]'.
I also find that if I round
pinv(H)*Treturn the same answer. So I guess one of the reason might be the float calculation issue inside the matlab.
cond(H)is large, any small change of
Hmay result in large difference in the inverse of
H. I think the
roundfunction may not be a good option to test. As Cris Luengo mentioned, with large
cond,the numerical imprecision will affect the accuracy of inverse.
In my test, I use 1000 training samples with noise between
[-0.2,0.2], and test samples are noise free. 20 neurons are selected. The
OW = pinv(H)*Tcan give reasonable results for
SinCtraining, while the performance for
OW = pinv(H'*H)*Tis worse. Then I try to increase the precision of
pinv(vpa(H'*H)), there's no significant improvement.
Does anyone know how to solve this?
Is there a step-by-step description that enables me to produce a sensor error model for an IMU?
I've noticed sensor error models produced within the following for the IMU used:
2) Ferraris, F., Grimaldi, U., & Parvis, M. (1995). Procedure for effortless in-field calibration of three-axis rate gyros and accelerometers. Sensors and Materials, 7, 311-311.
However, I'm still unclear as to how to create the sensor models for the MEMS IMU for a commercial device. Any resources that help me go through it step-by-step in layman terms?
How to combine Wavelet Transform and Frequency Filtering
I need to implement the following de-noising on ECG signal:
- Discrete wavelet transform to 9 levels with 'db6' wavelet
- Filter the frequencies (not the details coefficients) on the 9-th level in the range 0-0.35Hz
- Reconstruct the signal using only the levels 3 to 9
I do not know how to perform the second step in Python (PyWavelets), because I can modify only the detail and approximation coefficients and I do not know how to relate them to the frequencies.
How should I proceed?
This is my code
import pywt #DWT coeff = pywt.wavedec(data,'db6',level=9) #filter the 0-0.35Hz frequencies in the 9-th level? #reconstruct the signal y = pywt.waverec( coeff[:8]+ [None] * 2, 'db6' )
Python wavelets pywt A(pproximation) and D(etail) coefficient meaning
As I am not fluent in the Wavelet reconstruction process, can anyone explain the meaning of these two coefficients?
For example, for the following series:
import pywt (cA, cD) = pywt.dwt([1, 2, 3, 4, 5, 6], 'db1')
cA==array([ 2.12132034, 4.94974747, 7.77817459]) cD==array([-0.70710678, -0.70710678, -0.70710678])
How to implement a 3D wavelet transform with Matlab using the 1D wavelet transform (using dwt() from matlab)?
I am trying to implement a 3D wavelet transform using the already built-in Matlab function dwt from the wavelet toolbox. Any hints ?