logp=0#instantaneous log-likelihood for positive jumps
logn=0#instantaneous log-likelihood for negative jumps
cpos=np.zeros(len(data),dtype='float64')#cumulative log-likelihood function for positive jumps
cneg=np.zeros(len(data),dtype='float64')#cumulative log-likelihood function for negative jumps
gpos=np.zeros(2,dtype='float64')#decision function for positive jumps
gneg=np.zeros(2,dtype='float64')#decision function for negative jumps
edges=np.array([0],dtype='int64')#initialize an array with the position of the first subevent - the start of the event
real_start=np.array([],dtype='int64')#initialize an array with the position of the first subevent - the start of the event
real_end=np.array([],dtype='int64')#initialize an array with the position of the first subevent - the start of the event
real_Depth=np.array([],dtype='int64')#initialize an array with the position of the first subevent - the start of the event
anchor=0#the last detected change
length=len(data)
self.var=np.std(data)
h=threshhold/self.var
k=1000
nStates=0
varM=data[0]
varS=0
mean=data[0]
print('length data ='+str(length))
v=np.zeros(length,dtype='float64')
whilek<length-100:
k+=1
ifnStates==0:
variance=np.var(data[anchor:k])# initial params for pattern region
mean=np.mean(data[anchor:k])
ifvariance==0:break
logp=threshhold/variance*(data[k]-mean-threshhold/2.)#instantaneous log-likelihood for current sample assuming local baseline has jumped in the positive direction
logn=-threshhold/variance*(data[k]-mean+threshhold/2.)#instantaneous log-likelihood for current sample assuming local baseline has jumped in the negative direction