% Generate an 11x11 grid of training points from a scalar function of
% 2 inputs with Gaussian noise. Save the numbers to the file "trains1".
% Generate a 65x65 grid of test points from the same function without
% added noise and save to "tests1". All inputs and outputs are normalised
% to zero mean and unit (sample) standard deviation on the training cases.

randn('seed', 23)                                 % set seed for random numbers
[XX,YY] = meshgrid(-2:4/10:2, -2:4/10:2);             % grid of training inputs
X=reshape(XX,121,1); Y=reshape(YY,121,1);
stdX=std(X); stdY=std(Y);                              % normalising for inputs
Z=(sin(3*X)+exp(0.5*Y)).*exp((-X.^2-Y.^2)/4)+0.3*randn(121,1);
meanZ=mean(Z); stdZ=std(Z);                           % normalizing for outputs
trains1 = [X/stdX Y/stdY (Z-meanZ)/stdZ];
save -ascii trains1 trains1 

X2 = [randn(60,2)*.9 + ones(60,1) * [-.5, 0];
      randn(60,2)*.3 + ones(60,1) * [1, -1]] ;
Z2 = (sin(3*X2(:,1))+exp(0.5*X2(:,2))).*exp((-X2(:,1).^2-X2(:,2).^2)/4)+ ...
      0.3*randn(120,1);
X2 = X2 * diag([1/stdX, 1/stdY]) ;
Z2 = (Z2 - meanZ)/stdZ ;
trains2 = [X2, Z2] ;

save -ascii trains2 trains2

[XX,YY]=meshgrid(-2:4/64:2, -2:4/64:2);                   % grid of test inputs
X=reshape(XX,4225,1); Y=reshape(YY,4225,1);
Z=(sin(3*X)+exp(0.5*Y)).*exp((-X.^2-Y.^2)/4);                 % don't add noise
tests1 = [X/stdX Y/stdY (Z-meanZ)/stdZ];
save -ascii tests1 tests1 
