A stochastic version of the delta rule