a detail, but the division here is not necessary due to `weights /= w_sum` below