Solution

ID: past-exam-of-the-mathematics-course-of-the-university-of-cambridge/2022/ii/paper-4/28k/c/solution

Take the proposal density . For the target half-normal distribution,
The ratio is maximized at , so the sharp envelope constant is
Generate and an independent uniform , and accept when

New to topics? Read the docs here!