def __init__(self, P, pobs, pi=None, dt_model='1 step'): """ Parameters ---------- Pcoarse : ndarray (m,m) coarse-grained or hidden transition matrix Pobs : ndarray (m,n) observation probability matrix from hidden to observable discrete states dt_model : str, optional, default='1 step' time step of the model """ # construct superclass and check input _MSM.__init__(self, P, dt_model=dt_model) self.set_model_params(pobs=pobs, pi=pi, dt_model=dt_model)
def __init__(self, samples, ref=None, conf=0.95): r""" Constructs a sampled MSM Parameters ---------- samples : list of MSM Sampled MSM objects ref : obj of type :class:`pyemma.msm.MaximumLikelihoodMSM` or :class:`pyemma.msm.BayesianMSM` Single-point estimator, e.g. containing a maximum likelihood or mean MSM conf : float, optional, default=0.95 Confidence interval. By default two-sigma (95.4%) is used. Use 95.4% for two sigma or 99.7% for three sigma. """ # validate input assert is_iterable( samples), 'samples must be a list of MSM objects, but is not.' assert isinstance( samples[0], MSM), 'samples must be a list of MSM objects, but is not.' # construct superclass 1 SampledModel.__init__(self, samples, conf=conf) # construct superclass 2 if ref is None: Pref = self.sample_mean('P') MSM.__init__(self, Pref, dt_model=samples[0].dt_model, neig=samples[0].neig, ncv=samples[0].ncv) else: MSM.__init__(self, ref.Pref, pi=ref.pi, reversible=ref.reversible, dt_model=ref.dt_model, neig=ref.neig, ncv=ref.ncv)
def __init__(self, dtrajs, dt_traj, lag, connectivity, active_set, connected_sets, C_full, C_active, transition_matrix): r"""Estimates a Markov model from discrete trajectories. Parameters ---------- dtrajs : list containing ndarrays(dtype=int) or ndarray(n, dtype=int) discrete trajectories, stored as integer ndarrays (arbitrary size) or a single ndarray for only one trajectory. dt_traj : str, optional, default='1 step' Description of the physical time corresponding to the trajectory time step. May be used by analysis algorithms such as plotting tools to pretty-print the axes. By default '1 step', i.e. there is no physical time unit. Specify by a number, whitespace and unit. Permitted units are (* is an arbitrary string): | 'fs', 'femtosecond*' | 'ps', 'picosecond*' | 'ns', 'nanosecond*' | 'us', 'microsecond*' | 'ms', 'millisecond*' | 's', 'second*' lagtime : int lagtime for the MSM estimation in multiples of trajectory steps connectivity : str, optional, default = 'largest' Connectivity mode. Three methods are intended (currently only 'largest' is implemented) * 'largest' : The active set is the largest reversibly connected set. All estimation will be done on this subset and all quantities (transition matrix, stationary distribution, etc) are only defined on this subset and are correspondingly smaller than the full set of states * 'all' : The active set is the full set of states. Estimation will be conducted on each reversibly connected set separately. That means the transition matrix will decompose into disconnected submatrices, the stationary vector is only defined within subsets, etc. Currently not implemented. * 'none' : The active set is the full set of states. Estimation will be conducted on the full set of states without ensuring connectivity. This only permits nonreversible estimation. Currently not implemented. active_set : connected_sets : C_full : C_active : transition_matrix : """ # superclass constructor MSM.__init__(self, transition_matrix, dt_model=TimeUnit(dt_traj).get_scaled(lag)) # Making copies because we don't know what will happen to the arguments after this call self.lag = lag self.connectivity = copy.deepcopy(connectivity) self.active_set = copy.deepcopy(active_set) self._dtrajs_full = copy.deepcopy(dtrajs) self.dt_traj = dt_traj self._C_full = copy.deepcopy(C_full) self._C_active = copy.deepcopy(C_active) self._connected_sets = copy.deepcopy(connected_sets) # calculate secondary quantities self._nstates_full = np.shape(C_full)[0] # full2active mapping self._full2active = -1 * np.ones(self._nstates_full, dtype=int) self._full2active[self._active_set] = np.array(list( range(len(self._active_set))), dtype=int) # is estimated self._is_estimated = True