code: public double calculateStochasticUpdate(double[] x, double xscale, int batchSize, double gain) {
      getBatch(batchSize);
      return calculateStochasticUpdate(x, xscale, thisBatch, gain);
    }
docs: Performs stochastic update of weights x (scaled by xscale) based
  on next batch of batchSize
  @param x - unscaled weights
  @param xscale - how much to scale x by when performing calculations
  @param batchSize - number of samples to pick next
  @param gain - how much to scale adjustments to x
  @return value of function at specified x (scaled by xscale) for samples