When a drafted token is rejected, the replacement is sampled from the residual distribution, the part of the target that the draft under-covered. Together with the acceptance rule this keeps the output exactly target-distributed.
Implement residual_distribution(p, q), the positive part of the difference, renormalized.
Take the element-wise maximum of p minus q and zero, then divide by its sum.
No results yet
Run your code to check it against the examples, or submit to run every test.