#NEWLINE# def get_word_variational( self , Data , LP ) : #NEWLINE# #INDENT# ' Update and return word-topic assignment variational parameters\n        ' #NEWLINE# wv = LP [ 'word_variational' ] #NEWLINE# K = wv . shape [ 1 ] #NEWLINE# wv [ : ] = LP [ 'E_logsoftev_WordsData' ] #NEWLINE# ElogPi = LP [ 'E_logPi' ] [ : , : K ] #NEWLINE# for d in xrange ( Data . nDoc ) : #NEWLINE# #INDENT# wv [ Data . doc_range [ ( d , 0 ) ] : Data . doc_range [ ( d , 1 ) ] , : ] += ElogPi [ d , : ] #NEWLINE# #UNINDENT# colIDs = np . argmax ( wv , axis = 1 ) #NEWLINE# R = scipy . sparse . csr_matrix ( ( np . ones ( Data . nObs ) , colIDs , np . arange ( ( Data . nObs + 1 ) ) ) , shape = ( Data . nObs , K ) , dtype = np . float64 ) #NEWLINE# LP [ 'word_variational' ] = R . toarray ( ) #NEWLINE# assert np . allclose ( 1.0 , np . sum ( LP [ 'word_variational' ] , axis = 1 ) ) #NEWLINE# return wv