On the Geometric Structure of Problems in Statistics and Optimization