Stochastic model for magnetic hysteresis