Probability correction, Analytical python script