简体   繁体   中英

How to calculating Zero Crossing Rate (ZCR) & Mean Crossing Rate (MCR) in an array?

I am trying to create two python methods that provides ZCR & MCR of an array as mentioned in the research paper

在此处输入图片说明

Here are my code for ZCR :

    def getZeroCrossingRate(self,arr):
        my_array = np.array(arr)
        return float("{0:.2f}".format((((my_array[:-1] * my_array[1:]) < 0).sum())/len(arr)))
Input  : [1,2,-3,4,5,-6,-2,-6,2]
Output : 0.44

For MCR , should i average out the ZCR calculated from other segments ?

You can use your ZCR function to compute the MCR like so:

def getMeanCrossingRate(self, arr):
    return self.getZeroCrossingRate(np.array(arr) - np.mean(arr))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM