public static Integer[] fudge(Integer layer[]){
		Random rand = new Random();
		int len = layer.length-1;
		int i = 0, curDepth = 0;

		//skip to the location of the top layer (pass over nulls)
		while(layer[i] == null && i < len)
			i++;

		int top = curDepth = i;
		double depth;

		//do not fudge the top layer
		i++;

		//for the remaining layers
		for(; i<len; i++){
			BufferedWriter bw = null;
			try {
				//file for logging the fudge values
				bw = new BufferedWriter(new FileWriter("fudge.txt", true));

				//TODO Verify calculations are correct.
				//100/XML%
				//((100/Grid.removeValue*(len/i)) == 0)
				//randomly remove a layer from results
				if((rand.nextDouble()*100) < Grid.removePercentage ) {
					if(rand.nextInt((len/i)) == 0){
						//done by not incrementing curDepth
						bw.write("layer " + layer[i] + " removed.\n");
					}
				}
				//skew the depth of the layer in the results
				//if the layer exists
				else if (layer[i] != null){
					//curDepth to skip layers that are taken out
					curDepth++;

					//randomly choose to add or subtrace
					int a = rand.nextInt(1);

					//the depth of the current layer
					depth = layer[top] - layer[i];

					int before = layer[i];
					double random = rand.nextDouble();

					/*Uniformly distributed random decimal from 0 to 1,
							times the set XML percentage,
							times the elevation adjusted for depth */
					// (0.0 - 1.0) * (0.1) * (top layer + depth)
					double fudge = ((random * ((double)Grid.fudgeValue/100.0)) * depth);

					if(a==0)
						layer[curDepth] = layer[i] + (int)fudge;
					else
						layer[curDepth] = layer[i] - (int)fudge;

					int amount = Math.abs(before-layer[curDepth]);
					String output = String.format("fudgeValue: %d, rand: %.4f, depth: %2f, "+
							"before: %d, after: %d, amount: %3d, percent: %5.3f\n"
							, Grid.fudgeValue,random,depth,before,layer[i],
							amount,(double)((double)amount)/(double)before);
					bw.write(output);
				}
				bw.close();	
			}
			catch (IOException e) {
				e.printStackTrace();
			}
		}
		return Arrays.copyOfRange(layer,0,curDepth+1);
	}