This type conversion to float will cause an Overflow Error when z0 is too large. As Python does floating point division by default, this cast is unnecessary. Replacing the line by p = z0 / (z0+z1) solves the problem. Optionally, one could invert the division to remove the need to divide by z0+z1.