Karl Pearson’s Algorithm in Python