def test_its_hmsm(self): estimator = msm.timescales_hmsm([self.double_well_data.dtraj_T100K_dt10_n6good], 2, lags = [1, 10, 100], n_jobs=2) ref = np.array([[ 222.0187561 ], [ 339.47351559], [ 382.39905462]]) assert np.allclose(estimator.timescales, ref, rtol=0.1, atol=10.0) # rough agreement
def test_its_hmsm(self): estimator = msm.timescales_hmsm([self.double_well_data.dtraj_T100K_dt10_n6good], 2, lags = [1, 10, 100]) ref = np.array([[ 222.0641768 ], [ 336.530405 ], [ 369.57961198]]) assert np.allclose(estimator.timescales, ref, rtol=0.1, atol=10.0) # rough agreement
def plotTimescales(self, lags=None, errors=None, nits=5, results=False, plot=True): """ Plot the implied timescales of MSMs of various lag times Parameters ---------- lags : list The lag times at which to compute the timescales. By default it spreads out 25 lag times linearly from lag 10 until the mode length of the trajectories. errors : errors Calculate errors using Bayes (Refer to pyEMMA documentation) nits : int Number of implied timescales to calculate. Default: all results : bool If the method should return the calculated implied timescales plot : bool If the method should display the plot of implied timescales Returns ------- If given `results`=True this method will return the following data its : np.ndarray The calculated implied timescales. 2D array with dimensions (len(`lags`), `nits`) lags : np.ndarray A list of the lag times that were used to calculate the implied timescales Examples -------- >>> model = ModelHMM(data) >>> model.plotTimescales() >>> model.plotTimescales(lags=list(range(1,100,5))) """ import pyemma.plots as mplt import pyemma.msm as msm self._integrityCheck() if lags is None: lags = self._defaultLags() from htmd.config import _config its = msm.timescales_hmsm(self.data.St, nits, lags=lags, errors='bayes', nsamples=250, n_jobs=_config['ncpus']) if plot: plt.ion() plt.figure() mplt.plot_implied_timescales(its, dt=self.data.fstep, units='ns') plt.show() if results: return its.get_timescales(), its.lags
def plotTimescales(self, maxlag, numstates): import pyemma.msm as msm import pyemma.plots as mplt its = msm.timescales_hmsm(self.data.St.tolist(), numstates, lags=maxlag) mplt.plot_implied_timescales(its, ylog=True, units='ns', dt=self.data.fstep, linewidth=2)
def test_its_bhmm(self): estimator = msm.timescales_hmsm([self.double_well_data.dtraj_T100K_dt10_n6good], 2, lags = [1, 10], errors='bayes', nsamples=100) ref = np.array([[ 222.02102829], [ 342.49101981]]) # rough agreement with MLE assert np.allclose(estimator.timescales, ref, rtol=0.1, atol=10.0) # within left / right intervals. This test should fail only 1 out of 1000 times. L, R = estimator.get_sample_conf(conf=0.999) np.testing.assert_array_less(L, estimator.timescales) np.testing.assert_array_less(estimator.timescales, R)
def plotTimescales(self, maxlag): import pyemma.msm as msm import pyemma.plots as mplt its = msm.timescales_hmsm(self.hmm.discrete_trajectories_full, self.macronum, lags=maxlag) mplt.plot_implied_timescales(its, ylog=True, units='ns', dt=self.data.fstep, linewidth=2)