def plot_marginals(state_space,p,name,t,labels = False):
import matplotlib
#matplotlib.use("PDF")
#matplotlib.rcParams['figure.figsize'] = 5,10
import matplotlib.pyplot as pl
pl.suptitle("time: "+ str(t)+" units")
print("time : "+ str(t))
D = state_space.shape[1]
for i in range(D):
marg_X = np.unique(state_space[:,i])
A = np.where(marg_X[:,np.newaxis] == state_space[:,i].T[np.newaxis,:],1,0)
marg_p = np.dot(A,p)
pl.subplot(int(D/2)+1,2,i+1)
pl.plot(marg_X,marg_p)
pl.axvline(np.sum(marg_X*marg_p),color= 'r')
pl.axvline(marg_X[np.argmax(marg_p)],color='g')
if labels == False:
pl.xlabel("Specie: " + str(i+1))
else:
pl.xlabel(labels[i])
#pl.savefig("Visuals/marginal_"+name+".pdf",format='pdf')
pl.show()
pl.clf()
##Simple Compress : best N-term approximation under the ell_1 norm
#@param state_space the state space shape: (Number of Species X Number of states)
#@param p probability vector
#@param eps the ell_1 error to remove
#@return -Compressed state space
# -Compressed Probs
评论列表
文章目录