laszukdawid / PyEMD

Python implementation of Empirical Mode Decompoisition (EMD) method
https://pyemd.readthedocs.io/
Apache License 2.0
867 stars 224 forks source link

what about using percentages for "end_condition" #16

Closed emacsenli666 closed 6 years ago

emacsenli666 commented 6 years ago

considering some conditions that data might be very small ,and absolute end condition might not be precise enough. for example ,forex data, euro vs US dollar ,always range from 1.0000 to 1.6000 last decade,so absolute end condition "total_power_thr=0.001",is not precise enough for financial data.

emacsenli666 commented 6 years ago

currently ,I have to multiply forex data 100 times to meet precision need.that makes code looks wired.

laszukdawid commented 6 years ago

Hi @emacsenli666 Just noticed that scaling feature was not included in the release. Signals were supposed to be scaled such that the maximum value is 1 and thus total_power_thr=0.001 would be roughly 0.1% of the total value. Unfortunately, I'm busy in the coming two-three weeks, so won't be able to update code.

What you could do, however, is to manually change these values either by passing them as kwargs or updating directly. Examples of setting total_power_thr = 1e-5:

config = {"total_power_thr": 1e-5}
emd = EMD(**config)

or

emd = EMD()
emd.total_power_thr = 1e-5

Hope this helps, Dawid

emacsenli666 commented 6 years ago

See that @laszukdawid ,thanks for your quick answer.

right now I still have two questions. first, I am now wondering how to set up total_power_thr for eemd? eemd.total_power_thr=1e-6 or 1e-7 , is my code right? I will do some calculate later to check whether returned IMFs has required precision.

and second, I have noticed that IMFs containing some negative data while original signal are all positive. so threshold used in emd,just sum tmp together,shall we check each tmp point data with fixed threshold?

laszukdawid commented 6 years ago

EEMD uses EMD to decompose signal. Again, you have two options for updating these values

config = {"total_power_thr": 1e-6}
eemd = EEMD(**config)

or

eemd = EEMD()
eemd.EMD.total_power_thr = 1e-6

It's actually expected that IMFs will have negative values. Since they are meant to reflect oscillations with mean 0, there should be same amount above and below 0 value. The trend in data, i.e. non-oscillatory slow component, should be present in residue.

laszukdawid commented 6 years ago

A brief explanation on some thresholds is now included in thedocumentation (added 6aa5aa9dff0cd326e7c5262bc7729096a97d509f).