我想知道在Python中是否有一个一维小波能量的实现,与Matlab的'[Ea,Ed]=wenergy(C,L)'相同。
我试着自己写一篇,但我不确定:
公式为:
其中Dj是细节向量,j=1,2,…,ld和N1是分解层的数据长度。在
import json
import pywt
f=open('DataFile.txt','r')
D=json.load(f)
f.close()
#create the wavelet function
db1 = pywt.Wavelet('db13')
#calculate the number of necessary decompositions
NbrDecomp= pywt.dwt_max_level(len(D), db1)+1
#Initialize an empty list to receive the Detail and Approximation
Vector = [None] * NbrDecomp
#we use the Wavelet decomposition in the pywt module
Vector = pywt.wavedec(D, db1)
#Now Vector = [Approxiamtion N, Details N, Details N-1,.....]
#Where N would be the number of decompositions
根据定义,k级能量为:
^{pr2}$实施是否正确?在
您可以稍微简化代码:
可以重写为
^{pr2}$您可以将平方和求和作为一个NumPy操作来执行(因为您已经在使用NumPy了)
相关问题 更多 >
编程相关推荐