Protein folding as a stochastic process