% how much of the test data to keep
% mod=16,cap=4 means take 64 samples (16 sensors, 4 offsets) from each
% location. That way the samples we save are evenly spaced around the
% robot, rather than a lot of useless repeated samples.
thin_mod = 16;
thin_cap = 3;
raster_res = 2;
	
% load the map data and thin it down to reduce computation time
load map.ext;
thin;
	
% parse the map data into columns
mappy
	
% compute the sonar calibration function (linear)
coeff=fittyline;

error_ary = [];

% which observation to use as the test point
for test_ind = 1:28,
	% position to extract from map for testing
	matchpos = zuniq(test_ind);
	
	% extract a test set from the map data
	extract
	
	% compute the set of valid votes
	votes
	
	% tally the votes and plot it
	tally

	% print out the error result
	the_error = abs(matchpos-max_spot);
	disp(sprintf('thin_cap = %d   test_ind = %d  the_error = %f', thin_cap, test_ind, the_error));
	error_ary(test_ind) = the_error;
end

error_report;
