def mfptGraph(self): """ Not yet implemented """ import pyemma.plots as mplt self._intergrityCheck() #pos = np.array([[3,3],[4.25,0],[0,1],[1.75,0],[6,1.0]]) #state_colors = ['green', 'blue', 'yellow', 'cyan', 'purple'] # Color states by committor! on gradient from blue to red msm = self.model.msm state_sizes = msm.stationary_distribution ** 0.25 # Scale eq prob down to make states visible fig, pos = mplt.plot_markov_model(msm, state_sizes=state_sizes)
from pyemma import msm, plots from pyemma import plots as mplt import numpy as np import pdb import matplotlib.pyplot as plt P = np.array([[0.8, 0.15, 0.05, 0.0, 0.0], [0.1, 0.75, 0.05, 0.05, 0.05], [0.05, 0.1, 0.8, 0.0, 0.05], [0.0, 0.2, 0.0, 0.8, 0.0], [0.0, 0.02, 0.02, 0.0, 0.96]]) M = msm.markov_model(P) pos = np.array([[2.0, -1.5], [1, 0], [2.0, 1.5], [0.0, -1.5], [0.0, 1.5]]) pl = mplt.plot_markov_model(M, pos=pos) #pl[0].show() A = [0] B = [4] tpt = msm.tpt(M, A, B) # get tpt gross flux F = tpt.gross_flux print('**Flux matrix**:') print(F) print('**forward committor**:') print(tpt.committor) print('**backward committor**:') print(tpt.backward_committor) # we position states along the y-axis according to the commitor tptpos = np.array([tpt.committor, [0, 0, 0.5, -0.5, 0]]).transpose() print('\n**Gross flux illustration**: ')
pp.show() pp.clf() pp.close() ##### #make hmm from msm and pcca clusters hmm = msm_from_data.coarse_grain(n_sets) print 'hmm' print hmm.stationary_distribution print hmm.transition_matrix np.savetxt(os.path.join(args.save_destination, 'msm_populations.txt'), hmm.stationary_distribution) np.savetxt(os.path.join(args.save_destination, 'msm_transmat.txt'), hmm.transition_matrix) #plot msm using pyemma function mplt.plot_markov_model(hmm, minflux=4e-4, arrow_label_format='%.3f') if args.save: pp.savefig(os.path.join(args.save_destination, 'msm_hmm_markovmodel.png')) if args.display: pp.show() pp.clf() pp.close() #plot hmm timescales print hmm.metastable_assignments pp.plot(msm_from_data.timescales()[:-1] / msm_from_data.timescales()[1:], linewidth=0, marker='o') pp.xlabel('index') pp.ylabel('timescale separation')
pp.savefig(os.path.join(args.save_destination, 'msm_ck.png')) if args.display: pp.show() pp.clf() pp.close() ##### #make hmm from msm and pcca clusters hmm = msm_from_data.coarse_grain(n_sets) print 'hmm' print hmm.stationary_distribution print hmm.transition_matrix np.savetxt(os.path.join(args.save_destination, 'msm_populations.txt'), hmm.stationary_distribution) np.savetxt(os.path.join(args.save_destination, 'msm_transmat.txt'), hmm.transition_matrix) #plot msm using pyemma function mplt.plot_markov_model(hmm, minflux=4e-4, arrow_label_format='%.3f') if args.save: pp.savefig(os.path.join(args.save_destination, 'msm_hmm_markovmodel.png')) if args.display: pp.show() pp.clf() pp.close() #plot hmm timescales print hmm.metastable_assignments pp.plot(msm_from_data.timescales()[:-1]/msm_from_data.timescales()[1:], linewidth=0,marker='o') pp.xlabel('index'); pp.ylabel('timescale separation'); if args.save: pp.savefig(os.path.join(args.save_destination, 'msm_hmm_timescales.png')) if args.display: