brentq assumes that the objective function is continuous--but it isn't. It has flat spots and jumps
brentq assumes that evaluating the p-value at a particular shift always gives the same result, but that isn't true, because the p-value involves simulation. The randomness in the function needs to be taken into account; it will depend on the number of reps.