Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a parameter to set the type of interpolation for calculating the envelopes #41

Open
maciekKolbusz opened this issue Jan 31, 2018 · 5 comments
Milestone

Comments

@maciekKolbusz
Copy link

I think it may be useful to have a choice of the interpolation method for obtaining envelopes and include ie. quadratic, linear etc. in addition to the cubic spline, because in some situations it could be interesting to see how the results of the decomposition depend on the chosen interpolation method.

@jaidevd
Copy link
Owner

jaidevd commented Feb 1, 2018

Sure, we could expose the interpolation to the user.

But I wonder what this will really achieve. The cubic spline was chosen by Huang et al for a very specific reason, that it is smooth everywhere and almost always envelops the signal, ensuring that the IMFs are purely amplitude / frequency modulated. I'm pretty sure the results won't be physically meaningful if you use, say, a linear interpolant.

Regardless, this should be done. Might take some work, since interpolation is tightly coupled with the sifting methods (and wrongly so). So I'll take it up as an exercise in making things more modular.

@maciekKolbusz
Copy link
Author

It is true that cubic spline produces smooth fits, but in some cases, ie. when there are sharp spikes in the input signal, the envelopes tend to go their own ways and do not stick to the signal, because they are overly smooth in places. I believe (but haven't proven it yet) that this may be adding to the end-point effect and detrend uncertainty.

@jaidevd
Copy link
Owner

jaidevd commented Feb 1, 2018

Very interesting, could you share an example whenever you can?

@maciekKolbusz
Copy link
Author

Have a look at this slice of the plot, where the upper envelope formed a peak where there was actually a local dip:
cubic-spline1

The signal was the price of the stock and the envelope was generated with pandas.Series.interpolate() over the extrema located with scipy.signal.argrelmax().

Here's another real life example which simulates the scenario where analyst is watching the price of the stock and generates a new EMD model every day for 30 consecutive days. This period of 30 days was marked on the top subplot with the light blue line at the right end. The IMFs are all plotted on the same sublots, which means each subplot contains 30 curves of the particular IMF. The curves are colored from red to purple, red being the oldest (from the first day) and purple the latest (from the 30th day). One can see that IMFs 0 (the noise) through 3 hold their shapes quite well as the purple lines fully cover the red lines, however the plotted lines were of 1 point width and on the graph they appear thicker, which means that some inconsistencies exist. The end-point effect is visible in IMF 3 and becomes even stronger in IMF 4 through 6 where one can also see that purple lines significantly deviate from the red ones throughout the whole series.
vm-30day_emd

@jaidevd
Copy link
Owner

jaidevd commented Jan 11, 2021

Apologies for the delay on this, @maciekKolbusz

In the v0.2 release of PyHTT, we will allow users to choose their own interpolation method, the default being cubic splines.

@jaidevd jaidevd added this to the 0.2 Release milestone Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants