The proof of the Neyman-Pearson lemma relies on finding some threshold such that where is the likelihood ratio. If is continuous, then this is possible. But what if the distribution is discrete? In that case, we use randomization.
We still use a variant of the likelihood-ratio test, but it has the following form:
for some threshold and where is chosen such that has type-I error exactly . Therefore, solves . This might be considered a form of external randomization.