#NEWLINE# def log_likelihood( test_pdist , actual_pdist ) : #NEWLINE# #INDENT# if ( ( not isinstance ( test_pdist , ProbDistI ) ) or ( not isinstance ( actual_pdist , ProbDistI ) ) ) : #NEWLINE# #INDENT# raise ValueError ( 'expected a ProbDist.' ) #NEWLINE# #UNINDENT# return sum ( ( ( actual_pdist . prob ( s ) * math . log ( test_pdist . prob ( s ) , 2 ) ) for s in actual_pdist ) )