Optimization-based Distribution Estimation