function [estimate] = sprout(train, test)

# The following code tests the core assumption of BAMBOO;
# That simple variance pruning of the data has minimal impact on estimate accuracy.

# Step 0 : Load the Train/test data
data = load(train);
test = load(test);
[rows, cols] = size(data);

# Step 1 : Sort the rows in ascending order by their distance to the test instance
for i = 1 : rows
	distance = 0;
	for j = 1 : cols - 2
		distance = distance + power(data(i,j)-test(1,j),2);
	end
	data(i,cols+1) = distance;
end
[rows,cols] = size(data);
[junk, indices] = sort(data(:,cols));
data = data(indices,:);

# Step 2 : Pick a subset of the data, 100% chance to include if variance same/lower, 33% chance if variance increases
done = 0;
doneAt = 1;
oldVariance = var(data(1,1:cols-2));
for i = 1 : rows
	if (var(data(i,1:cols-2)) > oldVariance && done != 1)
		if (unidrnd(3) != 3)
			done = 1;
			doneAt = i;
		end
	end
	if (done == 0)
		oldVariance = var(data(i,1:cols-2));
	end
end

# Step 3 : Take the median as the estimate
estimate = median(data(1:doneAt,cols-1));
