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))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With