Stochastic Algorithms: Foundations and Applications