def cal_running_std(event_freq, n=16):
"""Calculate running standard deviation.
Parameters
----------
event_freq : numpy.ndarray
Event frequency count in given window
n : int
Running window for computing STD
Returns
-------
o : numpy.ndarray
Running standard deviation of given event frequency array
"""
q = event_freq[:, 1]**2
q = np.convolve(q, np.ones((n, )), mode="valid")
s = np.convolve(event_freq[:, 1], np.ones((n, )), mode="valid")
o = (q-s**2/n)/float(n-1)
return o
评论列表
文章目录