Stochastic Averaging and Optimal Prediction