Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. function [y, err] = mcm(N)
  2.  
  3. lowerBound = 0;
  4. upperBound = 1;
  5.  
  6. dim=5;
  7. S=0;
  8. fun = @(x_1, x_2, x_3, x_4, x_5)((x.^3)+3/4).*((x_1.^3)+3/4).*((x_2.^3)+3/4).*((x_3.^3)+3/4).*((x_4.^3)+3/4).*((x_5.^3)+3/4);
  9.  
  10. for i=1:N
  11. x=rand(1,dim);
  12. S=S+feval(fun,x);
  13. end
  14.  
  15. y = S / N;
  16.  
  17. err = abs(quad(fun, lowerBound, upperBound) - y(5));
  18.  
  19. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement