Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
technical:sliding_window [2019/09/25 14:25] – created chunchungtechnical:sliding_window [2020/10/13 19:27] – [Sliding window time histogram] chunchung
Line 1: Line 1:
 =====Sliding window time histogram===== =====Sliding window time histogram=====
 +Given the spike time, plot the event rate within a sliding window.
 <code python> <code python>
 def sliding_window(ts,wsz=10): def sliding_window(ts,wsz=10):
Line 36: Line 37:
     tts.append(tw)     tts.append(tw)
     rrs.append(0)     rrs.append(0)
-    return np.array(tts)+wsz/2,np.array(rrs)/bsize+    return np.array(tts)+wsz/2,np.array(rrs)/wsz
 </code> </code>
 +====Example====
 +<code python>
 +a = np.array([1,3,6,11,24,33,36,44,44,52,54,55,55,55,59,64])
 +tts,rrs = sliding_window(a)
 +plt.plot(tts,rrs,'-')
 +plt.plot(a,np.zeros_like(a),'x')
 +</code>
 +{{ :technical:sliding_window_example.svg |}}