Stochastic dynamics learning with state-space systems