Quantum methods for stochastic dynamics