Using Statistics to Automate Stochastic Optimization