A measure of the observed frequency of the symbol versus the expected frequency.
    If the value is 0 then the texts are exactly alike for that symbol.

def _calculate_chi_squared(source_freq, target_prob, source_len):
    """A measure of the observed frequency of the symbol versus the expected frequency.
    If the value is 0 then the texts are exactly alike for that symbol.
    """
    expected = source_len * target_prob
    return (source_freq - expected)**2 / expected