code: public void updateWeightAndPrune(float[] dataRow, int modelIndex, int ng, int bestIndex, float bestWeight) {
  		int index = modelIndex;
  		float weightTotal = 0;
  		for (int i = 0; i < ng;  ) {
  			float weight = dataRow[index];
  //			if( ng > 1 )
  //				System.out.println("["+i+"] = "+ng+"  weight "+weight);
  			weight = weight - learningRate*(weight + decay); // <-- original equation
  //			weight = weight - learningRate*decay;
  			if( weight <= 0 ) {
  				// copy the last Gaussian into this location
  				int indexLast = modelIndex + (ng-1)*gaussianStride;
  				for (int j = 0; j < gaussianStride; j++) {
  					dataRow[index+j] = dataRow[indexLast+j];
  				}
  
  				// see if the best Gaussian just got moved to here
  				if( indexLast == bestIndex )
  					bestIndex = index;
  
  				// mark it as unused by setting variance to zero
  				dataRow[indexLast+1] = 0;
  
  				// decrease the number of gaussians
  				ng -= 1;
  			} else {
  				dataRow[index] = weight;
  				weightTotal += weight;
  				index += gaussianStride;
  				i++;
  			}
  		}
  
  		// undo the change to the best model. It was done in the for loop to avoid an if statement which would
  		// have slowed it down
  		if( bestIndex != -1 ) {
  			weightTotal -= dataRow[bestIndex];
  			weightTotal += bestWeight;
  			dataRow[bestIndex] = bestWeight;
  		}
  
  		// Normalize the weight so that it sums up to one
  		index = modelIndex;
  		for (int i = 0; i < ng; i++, index += gaussianStride) {
  			dataRow[index] /= weightTotal;
  		}
  	}
docs: Updates the weight of each Gaussian and prunes one which have a negative weight after the update.