  Two parties sharing entangled quantum systems can generate correlations that
cannot be produced using only shared classical resources. These nonlocal
correlations are a fundamental feature of quantum theory but also have
practical applications. For instance, they can be used for device-independent
(DI) random number generation, whose security is certified independently of the
operations performed inside the devices. The amount of certifiable randomness
that can be generated from some given non-local correlations is a key quantity
of interest. Here we derive tight analytic bounds on the maximum certifiable
randomness as a function of the nonlocality as expressed using the
Clauser-Horne-Shimony-Holt (CHSH) value. We show that for every CHSH value
greater than the local value ($2$) and up to $3\sqrt{3}/2\approx2.598$ there
exist quantum correlations with that CHSH value that certify a maximal two bits
of global randomness. Beyond this CHSH value the maximum certifiable randomness
drops. We give a second family of Bell inequalities for CHSH values above
$3\sqrt{3}/2$, and show that they certify the maximum possible randomness for
the given CHSH value. Our work hence provides an achievable upper bound on the
amount of randomness that can be certified for any CHSH value. We illustrate
the robustness of our results, and how they could be used to improve randomness
generation rates in practice, using a Werner state noise model.
