Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

enter image description here

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 ?

like image 372
Taha Avatar asked Jan 21 '26 02:01

Taha


1 Answers

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))
like image 158
Moormanly Avatar answered Jan 22 '26 16:01

Moormanly