#NEWLINE# def sample( self , z , x , i , n ) : #NEWLINE# #INDENT# ' Sample the next state given the previous time index\n\n            :param z:       TxNxD buffer of particle states\n            :param x:       NxD output buffer for observations\n            :param i:       Time index to sample\n            :param n:       Particle index to sample\n        ' #NEWLINE# x_mean = np . dot ( self . C , z [ i , x_mean , : ] ) #NEWLINE# x_pi = np . exp ( x_mean ) #NEWLINE# x_pi /= np . sum ( x_pi ) #NEWLINE# from pybasicbayes.util.stats import sample_discrete #NEWLINE# s = sample_discrete ( x_pi ) #NEWLINE# x [ i , : ] = 0 #NEWLINE# x [ ( i , s ) ] = 1