public double UpdateWeights(double[] pattern, Neuron winner, int iteration)
    {
	double sum = 0;

	//For each of the connections
	for (int i = 0; i < weights.length; i++)
	{
	    //Calculate the change to be made to the connection weights.
	    //Learning rate                     //Gaussian neighbourhood function.
	    double delta = (Math.exp(-iteration / 1000) * 0.1) * Gauss(winner, iteration) * (pattern[i] - weights[i]);

	    //increment the connection weight.
	    weights[i] += delta;
	    sum += delta;
	}

	//the total changes made to weights divided by length.
	return sum / weights.length;
    }