#NEWLINE# def get_global_suff_stats( self , Data , LP , doPrecompEntropy = False , doPrecompMergeEntropy = False , mPairIDs = None ) : #NEWLINE# #INDENT# ' Count expected number of times each topic is used across all docs    \n    ' #NEWLINE# K = LP [ 'DocTopicCount' ] . shape [ 1 ] #NEWLINE# SS = SuffStatBag ( K = K , D = Data . vocab_size ) #NEWLINE# SS . setField ( 'nDoc' , Data . nDoc , dims = None ) #NEWLINE# sumLogPi = np . sum ( LP [ 'E_logPi' ] , axis = 0 ) #NEWLINE# SS . setField ( 'sumLogPiActive' , sumLogPi [ : K ] , dims = 'K' ) #NEWLINE# SS . setField ( 'sumLogPiUnused' , sumLogPi [ ( - 1 ) ] , dims = None ) #NEWLINE# if doPrecompEntropy : #NEWLINE# #INDENT# SS . setELBOTerm ( 'ElogpZ' , self . E_logpZ ( Data , LP ) , dims = 'K' ) #NEWLINE# ( logFactData , logFactZ ) = self . E_logfactorialZ ( Data , LP ) #NEWLINE# SS . setELBOTerm ( 'logFactData' , logFactData , dims = None ) #NEWLINE# SS . setELBOTerm ( 'logFactZ' , logFactZ , dims = 'K' ) #NEWLINE# ( ElogqPiC , ElogqPiA , ElogqPiU ) = self . E_logqPi_Memoized_from_LP ( LP ) #NEWLINE# SS . setELBOTerm ( 'ElogqPiConst' , ElogqPiC , dims = None ) #NEWLINE# SS . setELBOTerm ( 'ElogqPiActive' , ElogqPiU , dims = 'K' ) #NEWLINE# SS . setELBOTerm ( 'ElogqPiUnused' , ElogqPiU , dims = None ) #NEWLINE# #UNINDENT# if doPrecompMergeEntropy : #NEWLINE# #INDENT# ( ElogpZMat , sLgPiMat , ElogqPiMat ) = self . memo_elbo_terms_for_merge ( LP ) #NEWLINE# SS . setMergeTerm ( 'ElogpZ' , ElogpZMat , dims = ( 'K' , 'K' ) ) #NEWLINE# SS . setMergeTerm ( 'ElogqPiActive' , ElogqPiMat , dims = ( 'K' , 'K' ) ) #NEWLINE# SS . setMergeTerm ( 'sumLogPiActive' , sLgPiMat , dims = ( 'K' , 'K' ) ) #NEWLINE# SS . setMergeTerm ( 'logFactZ' , self . memo_factorial_term_for_merge ( LP , mPairIDs ) , dims = ( 'K' , 'K' ) ) #NEWLINE# #UNINDENT# return SS