On the probability that the maximum of a polynomial is at an endpoint of an interval