A sample of size n comes from the uniform law on [0, θ]. Test H0: θ = 2 against H1: θ < 2. The likelihood of a sample is θ−n once θ reaches the largest observation ymax and 0 before, so it peaks at θ = ymax (top panel). The generalized likelihood ratio λ = (ymax/2)n is the height of that curve at the null value θ = 2, as a fraction of the peak. When H0 is true λ is exactly uniform on (0, 1) (middle panel), so the test "reject if λ ≤ α" has level α. Compare its power curve (bottom panel) with a test of the same size that uses only the sample mean.
The middle panel uses the exact identity λ = (θ/2)n U with U uniform, which follows from ymax = θ U1/n, so a preset always shows the same values (seeded generator). The sample-mean test rejects when the sample mean is at most the α-quantile of its simulated null distribution; its curve is a simulation (20 000 samples) and wiggles by about 0.01. The exact power of the likelihood ratio test is min{1, α(2/θ)n}.
code/ch06_hypothesis_testing.py (glr_uniform, uniform_power, sim_mean_test_power).