Ejemplo n.º 1
0
 def reverse_cumulative_obs_potentials(self,tblock):
     t = self.segmentstarts[tblock] + self.segmentlens[tblock]
     possible_durations = rcumsum(self.segmentlens[:tblock+1])[-TRUNC if TRUNC is not None else None:]
     return np.hstack([hmm.reverse_cumulative_obs_potentials(self.aBls[state][:t],self,t)\
             [-possible_durations][:,na]
             # [possible_durations -1][:,na]
             for state, hmm in enumerate(self.model.HMMs)])
Ejemplo n.º 2
0
 def mf_reverse_cumulative_obs_potentials(self,tblock):
     return rcumsum(self.mf_aBl[:tblock+1])\
             [-self.trunc if self.trunc is not None else None:]
Ejemplo n.º 3
0
 def reverse_dur_survival_potentials(self,tblock):
     # NOTE: untested, unused
     max_dur = rcumsum(self.segmentlens[:tblock+1])\
             [-self.trunc if self.trunc is not None else None:][0]
     return self.aDsl[max_dur -1]
Ejemplo n.º 4
0
 def mf_reverse_cumulative_obs_potentials(self,t):
     start = 0 if self.trunc is None else max(0,t-self.trunc+1)
     return rcumsum(self.mf_aBl[start:t+1])
Ejemplo n.º 5
0
 def expected_log_sf(self,x):
     x = np.atleast_1d(x).astype('int32')
     assert x.ndim == 1
     inf = max(2*x.max(),2*1000) # approximately infinity, we hope
     return rcumsum(self.expected_log_pmf(np.arange(1,inf)),strict=True)[x]
Ejemplo n.º 6
0
 def _grad_log_p_beta(beta,alpha):
     # NOTE: switched argument name gamma <-> alpha
     return  -(alpha-1)*rcumsum(1./(1-cumsum(beta))) \
             + 2*rcumsum(1./(1-cumsum(beta,strict=True)),strict=True)
Ejemplo n.º 7
0
 def _grad_log_p_beta(beta,alpha):
     # NOTE: switched argument name gamma <-> alpha
     return  -(alpha-1)*rcumsum(1./(1-cumsum(beta))) \
             + 2*rcumsum(1./(1-cumsum(beta,strict=True)),strict=True)
Ejemplo n.º 8
0
 def mf_reverse_dur_potentials(self,tblock):
     possible_durations = rcumsum(self.segmentlens[:tblock+1])\
             [-self.trunc if self.trunc is not None else None:]
     return self.mf_aDl[possible_durations -1]
Ejemplo n.º 9
0
 def reverse_dur_survival_potentials(self,tblock):
     # NOTE: untested, unused
     max_dur = rcumsum(self.segmentlens[:tblock+1])\
             [-self.trunc if self.trunc is not None else None:][0]
     return self.aDsl[max_dur -1]
Ejemplo n.º 10
0
 def mf_reverse_cumulative_obs_potentials(self,tblock):
     return rcumsum(self.mf_aBl[:tblock+1])\
             [-self.trunc if self.trunc is not None else None:]
Ejemplo n.º 11
0
 def mf_reverse_cumulative_obs_potentials(self,t):
     start = 0 if self.trunc is None else max(0,t-self.trunc+1)
     return rcumsum(self.mf_aBl[start:t+1])
Ejemplo n.º 12
0
 def reverse_dur_survival_potentials(self,tblock):
     max_dur = rcumsum(self.segmentlens[:tblock+1])[-TRUNC if TRUNC is not None else None:][0]
     return self.aDsl[max_dur -1]
Ejemplo n.º 13
0
 def reverse_dur_potentials(self,tblock):
     possible_durations = rcumsum(self.segmentlens[:tblock+1])[-TRUNC if TRUNC is not None else None:]
     return self.aDl[possible_durations -1]
Ejemplo n.º 14
0
 def mf_reverse_dur_potentials(self,tblock):
     possible_durations = rcumsum(self.segmentlens[:tblock+1])\
             [-self.trunc if self.trunc is not None else None:]
     return self.mf_aDl[possible_durations -1]
Ejemplo n.º 15
0
 def mf_reverse_dur_survival_potentials(self,tblock):
     max_dur = rcumsum(self.segmentlens[:tblock+1])\
             [-self.trunc if self.trunc is not None else None:][0]
     return self.mf_aDsl[max_dur -1]
Ejemplo n.º 16
0
 def mf_reverse_dur_survival_potentials(self,tblock):
     max_dur = rcumsum(self.segmentlens[:tblock+1])\
             [-self.trunc if self.trunc is not None else None:][0]
     return self.mf_aDsl[max_dur -1]
Ejemplo n.º 17
0
 def expected_log_sf(self, x):
     x = np.atleast_1d(x).astype('int32')
     assert x.ndim == 1
     inf = max(2 * x.max(), 2 * 1000)  # approximately infinity, we hope
     return rcumsum(self.expected_log_pmf(np.arange(1, inf)),
                    strict=True)[x]