def p_topic_given_document(topic, d, alpha=0.1):
 return ((document_topic_counts[d][topic] + alpha) / (document_lengths[d] + (K * alpha)))

def p_topic_given_document ( topic , d , alpha = 0.1 ) : return ( ( document_topic_counts [ d ] [ topic ] + alpha ) / ( document_lengths [ d ] + ( K * alpha ) ) )
the fraction of words in document _d_ that are assigned to _topic_ .