  Quantum mechanics predicts the existence of intrinsically random processes.
Contrary to classical randomness, this lack of predictability can not be
attributed to ignorance or lack of control. Here we find the optimal method to
quantify the amount of local or global randomness that can be extracted in two
scenarios: (i) the quantum steering scenario, where two parties measure a
bipartite system in an unknown state but one of them does not trust his
measurement apparatus, and (ii) the prepare-and-measure scenario, where
additionally the quantum state is known. We use our methods to compute the
maximal amount of local and global randomness that can be certified by
measuring systems subject to noise and losses and show that local randomness
can be certified from a single measurement if and only if the detectors used in
the test have detection efficiency higher than 50%.
