  According to quantum theory, the outcomes obtained by measuring an entangled
state necessarily exhibit some randomness if they violate a Bell inequality. In
particular, a maximal violation of the CHSH inequality guarantees that 1.23
bits of randomness are generated by the measurements. However, by performing
measurements with binary outcomes on two subsystems one could in principle
generate up to two bits of randomness. We show that correlations that violate
arbitrarily little the CHSH inequality or states with arbitrarily little
entanglement can be used to certify that close to the maximum of two bits of
randomness are produced. Our results show that non-locality, entanglement, and
the amount of randomness that can be certified in a Bell-type experiment are
inequivalent quantities. From a practical point of view, they imply that
device-independent quantum key distribution with optimal key generation rate is
possible using almost-local correlations and that device-independent randomness
generation with optimal rate is possible with almost-local correlations and
with almost-unentangled states.
