import numpy as np from scipy.signal import argrelextrema def emd(data): """ 经验模式分解(Empirical Mode Decomposition,EMD) """ # 找到极值点 max_points, min_points = argrelextrema(data, np.greater, axis=0) max_points = np.array(max_points) min_points = np.array(min_points) # 使用样条插值求上、下包络线 upper_env = np.zeros(len(data)) lower_env = np.zeros(len(data)) for i in range(len(data)): upper_env[i] = np.interp(max_points, np.arange(len(data)), data[max_points]) lower_env[i] = np.interp(min_points, np.arange(len(data)), data[min_points]) # 求平均值作为固有模式函数(Intrinsic Mode Function,IMF) imf = (upper_env + lower_env) / 2 return imf # 用法示例: data = np.random.normal(size=1000) # 随机生成一组数据 imfs = emd(data) # 得到固有模式函数(IMF)的集合
###
标签:HHT,Python,max,min,points,env,np,data,Hilbert From: https://www.cnblogs.com/herd/p/17704722.html