<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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