Determining the interval of event occurrence in timeseries

384 Views Asked by At

Given different binary time series (zero shows no event, 1 shows the occurrence of an event), we can see the intervals at which the event occurs in the first plot is higher than the second and last one.
I wonder if I could use scipy statistics or something like Fourier Transform or timeseries decomposition(or other possible solutions in python) to detect and quantify the differences in the frequency of the event in these time-series. ** I know that I can measure the distance between the occurrences of number 1, but I am looking for a more robust way for more complicated timeseries. enter image description here the following code is used to generate some data used in the plots:

import pandas as pd 
import datetime as dt


x1=np.linspace(1, 1,num=60)
for n in range (1,60):
    if n % 2 == 0:
        x1[n*2-3:n*2]=0
x2=np.linspace(1, 1,num=60)
for n in range (0,60):
    if n % 3 == 0:
        x2[n+1:n+3]=0

x3=np.linspace(1, 1,num=60)
for n in range (0,60):
    if n % 2 == 0:
        x3[n+1:n+2]=0

df=pd.DataFrame([x1,x2,x3]).T
df['date'] = (pd.date_range(start=dt.datetime(2018, 1, 1), 
                     periods=df.shape[0], 
                     freq='D'))][1]][1]
0

There are 0 best solutions below