import numpy as np
# 均方根
def featureRMS(data):
return np.sqrt(np.mean(data ** 2, axis=0))
# 取绝对值求各列均值
def featureMAV(data):
return np.mean(np.abs(data), axis=0)
# 求离散的差值,按列的后尾元素向上面的元素进行求差,然后取绝对值再求所有矩阵同一元素位置的和,最后除以矩阵个数
def featureWL(data):
return np.sum(np.abs(np.diff(data, axis=0)), axis=0) / data.shape[0]
#
def featureZC(data, threshold=10e-7):
numOfZC = []
channel = data.shape[1]
length = data.shape[0]
for i in range(channel):
count = 0
for j in range(1, length):
diff = data[j, i] - data[j - 1, i]
mult = data[j, i] * data[j - 1, i]
if np.abs(diff) > threshold and mult < 0:
count = count + 1
numOfZC.append(count / length)
return np.array(numOfZC)
def featureSSC(data, threshold=10e-7):
numOfSSC = []
channel = data.shape[1]
length = data.shape[0]
for i in range(channel):
count = 0
for j in range(2, length):
diff1 = data[j, i] - data[j - 1, i]
diff2 = data[j - 1, i] - data[j - 2, i]
sign = diff1 * diff2
if sign > 0:
if (np.abs(diff1) > threshold or np.abs(diff2) > threshold):
count = count + 1
numOfSSC.append(count / length)
return np.array(numOfSSC)
能请教一下 MAV 、WL 、ZC 、SSC4 个函数的都是啥数学公式? 网上搜的那些都搜不到😅
大学数学早就还给老师了.....
1
noqwerty 2022-04-06 22:34:02 +08:00
|
2
noqwerty 2022-04-06 22:34:46 +08:00 1
似乎这里都包括了? Mean Absolute Value, Waveform Length, Zero Crossing, 和 Slope Sign Change
|