def _compute_samples(self):
     """Gives the corresponding KJMA kinetics for all samples 
     given by the MCMC routine.
     
     Parameters
     ----------
     thetas : array
         Array of shape (N_sample,N_theta).
     
     param : dict 
         Dict of keys {'y', 'u', ...}
     
     Returns
     -------
     samples : dict of arrays
         For key in {'I','s','rho_ini','rho_ter'}, 
            `samples[key]` array of shape (N_y, N_u, N_sample)
         For key in {'T','p','d_ini','d_ter'}, 
            `samples[key]` array of shape (N_y, N_sample)
         For key = 'theta',
            `samples[key]` array of shape (range_y, range_u, N_sample)
     
     """ 
     thetas, param = self._thetas, self._param
     
     Nx, Nt, N_sample = len(self.x), len(self.t), thetas.shape[0]
     keys_yu = {'I','s','rho_ini','rho_ter'}
     keys_y = {'d_ini','d_ter','T','p'}
     samples = {}
     for key in keys_yu: 
         samples[key] = np.zeros((Nx,Nt,N_sample))
     for key in keys_y: 
         samples[key] = np.zeros((Nx,N_sample))
     samples['theta'] = np.zeros((param['range_y'],param['range_u'],N_sample))
     
     dx, dt = self.x[1]-self.x[0], self.t[1]-self.t[0]
     lim = {'v':self.v, 'dy':dx,'du':dt}
     for s in range(N_sample):
         theta = thetas[s,:]
         C0_theta = product_C0_vec(param, theta)
         m = param['m_0'] + C0_theta
         I = 10**m
         I = I.reshape(param['Ny'],param['Nu'])
         # if FixedOris, we need to convert I to I_xt (postion x, time t, unit ini/kb/min)
         if self.FixedOris: I = self._get_I_xt_from_I_it(I_it=I)
         KJMA = compute_KJMA_kinetics_all(I=I, lim=lim) 
         for key in keys_yu: samples[key][:,:,s] = KJMA[key]
         for key in keys_y: samples[key][:,s] = KJMA[key]
         samples['theta'][:,:,s] = theta.reshape(param['range_y'],param['range_u'])
     
     self.samples = samples
 def compute_MAP(self, verbose=False):
     """Computes the MAP estimates of I and all replication kinetics 
     quantities, such as the replication timing distribution P, 
     the right-moving fork density rho_r, etc.
     """
     
     # compute I_MAP if necessary
     if self.I_MAP is None: self.compute_I_MAP(verbose)
     tic = time.clock()
     # I matrix I_xt (position x, time t, unit ini/kb/min)
     I = self._get_I_xt_from_I_it(I_it=self.I_MAP) if self.FixedOris else self.I_MAP
     dx, dt = self.x[1]-self.x[0], self.t[1]-self.t[0]
     lim = {'v':self.v, 'dy':dx,'du':dt}
     KJMA = compute_KJMA_kinetics_all(I=I, lim=lim) 
     if verbose: print "KJMA kinetics computed in {}s".format(time.clock()-tic)
     # theta reshaped as matrix range_y * range_u
     range_y, range_u = self._param['range_y'],self._param['range_u']
     KJMA['theta'] = self._theta_MAP.reshape(range_y, range_u)
     self.MAP = KJMA