An improper estimator with optimal excess risk in misspecified density estimation and logistic regression (Journal of Machine Learning Research, 2026)