pythonwavelet

How to calculate wavelet energy-to-Shannon entropy ratio to select best mother discrete wavelet in python?


I'm doing a wavelet analysis to sensor data, however, I realise that there are a lot of wavelet families to select from. I have read an article that says: "The method firstly uses a criterion of maximum energy-to-Shannon entropy ratio to select the appropriate wavelet base for signal analysis.". So, I would like to know how to calculate the energy-to-Shannon entropy ratio of a sensor signal in python?


Solution

  • Best guess assuming the text meant : np.max(Total Energy/Total Entropy)|wavelet

    import pywt
    import numpy as np
    
    #series - input data
    #wave   - current wavelet
    data=pywt.wavedec(series,wave)
    S=0
    Etot=0
    for d in data:
        E=d**2
        P=E/np.sum(E)
        S+=-np.sum(P*np.log(P))
        Etot+=np.sum(E)
    ratio=Etot/S
    

    Then repeated for each candidate wavelet