Stochastic optimization with arbitrary recurrent data sampling