function data = generate2d(name,isnoise,npoints)
%
%
%

n=npoints;
range = 10;
noise = 40;
dim = 2;

if strcmp(name,'cubic')
   x = [-1:2/n:+1-2/n]';
	y=((range*x).^3+noise*randn(n,1))/range^3;
   data = [x y];
elseif strcmp(name,'cubic+line')
      x = [-1:2/n:+1-2/n]';
		y=((range*x).^3+noise*randn(n,1))/range^3;
   	data1 = [x y];      
		y2 = [-1:2/n:+1-2/n]';
		x2 = 0.5+randn(n,1)/100;
   	data2 = [x2 y2];
      data = [data1' data2']';
elseif strcmp(name,'cubic+line+box')
      x = [-1:2/n:+1-2/n]';
		y=((range*x).^3+noise*randn(n,1))/range^3;
   	data1 = [x y];      
		y2 = [-1:2/n:+1-2/n]';
		x2 = 0.5+randn(n,1)/100;
   	data2 = [x2 y2];         
		y2 = [-1:.5/n:-0.5-.5/n]';
		x2 = -0.1+randn(n,1)/10;
      data3 = [x2 y2];
      data = [data1' data2' data3']';      

end

if isnoise
   y2 = randn(n/10,1)/2;
	x2 = randn(n/10,1)/2;
	data4 = [x2 y2];
	data = [data' data4']';
end
