function [d,a ] =  generate(a)

if( a.seed>0) RandStream.setGlobalStream(RandStream('mcg16807', 'Seed',a.seed));   end;

Z=unifrnd(-a.cov_r,a.cov_r,a.n,a.dim);
for i=1:a.corrdim
    Z(:,i)=a.coef(i).*Z(:,i);
end


if (a.corrdim==1) 
    temp=sin(Z(:,1))./(1+Z(:,1).^2);
elseif (a.corrdim==2) 
    temp=Z(:,1).*Z(:,2)./(1+Z(:,1).^2);
else temp=0;   
    for i=1:(a.corrdim-1)
         temp=temp+Z(:,i).*Z(:,i+1)./(1+Z(:,i).^2);
    end
    temp=temp+Z(:,a.corrdim).*Z(:,1)./(1+Z(:,a.corrdim).^2);
end
 
Y=temp;
d=data(Z,Y);
