Revised stochastic weight updates and added algorithm pseudo-code.