
function [data] = lots_of_gaussian_distributions ( gX, gY, width, N, xdata )

data = 0*(1:gX)'*(1:gY);

if nargin == 5
	data = data + xdata;
end

extra = 1;
limX = gX + 2*extra*width;
limY = gY + 2*extra*width;

% we only generate this data once.

gdata = gaussian( 2*(gX+extra*width)-1, 2*(gY+extra*width)-1, ...
	gX+extra*width, gY+extra*width, width );

% the ranges for edges of the data slice we want are
% left:      1 : gX+2*extra*width
% right:    gX : 2*gX+2*extra*width-1
% top:       1 : gY+2*extra*width
% bottom:   gY : 2*gY+2*extra*width-1


for ii = 1:N,
   indX = floor(rand*(gX+2*extra*width));
   indY = floor(rand*(gY+2*extra*width));
   mul = 2*floor(2*rand)-1;
   data = data + mul*gdata((indX+1):(indX+gX),(indY+1):(indY+gY));
end
