#NEWLINE# def mixture_loglike( data , thetas , covs , labels ) : #NEWLINE# #INDENT# n = len ( data ) #NEWLINE# likes = pdfs . mvnpdf ( data , thetas , covs ) #NEWLINE# loglike = likes . ravel ( 'F' ) . take ( ( ( labels * n ) + np . arange ( n ) ) ) . sum ( ) #NEWLINE# if np . isnan ( loglike ) : #NEWLINE# #INDENT# return ( - 1e+300 ) #NEWLINE# #UNINDENT# return loglike #NEWLINE# if np . isnan ( likes ) . any ( ) : #NEWLINE# #INDENT# loglike = 0.0 #NEWLINE# for ( j , ( theta , cov ) ) in enumerate ( zip ( thetas , covs ) ) : #NEWLINE# #INDENT# this_data = data [ ( labels == j ) ] #NEWLINE# ch = chol ( cov ) #NEWLINE# loglike += pm . mv_normal_chol_like ( this_data , theta , ch ) #NEWLINE# #UNINDENT# return loglike