Added costFunction and gradient for stochastic gradient descent. Added SGD algorithm.