
Npow=10; N=4^Npow;
f=inline('x.*cos(y).*exp(w).*(z.^10)','x','y','w','z');
Iex=(1/2)*(sin(1)-sin(0))*(exp(1)-1)*(1/11);

% MONTECARLO.
X=rand(N,4);
fX=feval(f,X(:,1),X(:,2),X(:,3),X(:,4));
Imc=sum(fX)/N;

% SOBOL.
P=sobolset(4); X= net(P,4^Npow);
fX=feval(f,X(:,1),X(:,2),X(:,3),X(:,4));
Isb=sum(fX)/N;

fprintf('\n \t [N pt]: %1.16e \n',N);

fprintf('\n \t [I.EX]: %1.16e',Iex);
fprintf('\n \t [I.MC]: %1.16e',Imc);
fprintf('\n \t [I.Sb]: %1.16e \n',Isb);

fprintf('\n \t [E.MC]: %1.16e',abs(Iex-Imc));
fprintf('\n \t [E.Sb]: %1.16e \n \n',abs(Iex-Isb));

