Uncertainty Quantification for Ill-Posed Inverse Problems in the Physical Sciences: Confidence Intervals via Optimization and Sampling