public double[] randomRehearsalSerialLearning(double[][] baseinputs, double[][] baseoutputs, 
			double[][] serialinputs, double[][] serialoutputs, double maxerror, int bufferSize) {
		Random r = new Random();
		double[] outputs = new double[serialinputs.length + 1];	

		double error = maxerror + 1;
		int counter = 0;
		// train base population
		while (maxerror < error && counter++ < quitCounter) {
			for (int i = 0; i < baseinputs.length; i++) {
				Pattern trial = new Pattern(baseinputs[i], baseoutputs[i]);
				pass(trial);
				updateAllWeights(trial);
			}
			error = populationError(outputs(baseinputs), baseoutputs);
		}
		outputs[0] = error;

		for (int i = 0; i < serialinputs.length; i++) {
			
			double[][] rehearseinputs = new double[bufferSize + 1][];
			double[][] rehearseoutputs = new double[bufferSize + 1][];
			for (int j = 0; j < rehearseinputs.length - 1; j++) {
				int n = r.nextInt(rehearseinputs.length);
				rehearseinputs[j] = baseinputs[n];
				rehearseoutputs[j] = baseoutputs[n];
			}
			rehearseinputs[rehearseinputs.length-1] = serialinputs[i];
			rehearseoutputs[rehearseoutputs.length-1] = serialoutputs[i];

			error = maxerror + 1;
			counter = 0;
			while (maxerror < error && counter++ < quitCounter) {
				for (int j = 0; j < rehearseinputs.length; j++) {
					Pattern trial = new Pattern(rehearseinputs[j], rehearseoutputs[j]);
					pass(trial);
					updateAllWeights(trial);
				}
				error = populationError(outputs(rehearseinputs), rehearseoutputs);
			}

			double poperror = populationError(outputs(baseinputs), baseoutputs);
			outputs[i+1] = poperror;
		}
		
		return outputs;
	}