Facebook
From Stained Stork, 7 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 273
  1. function y = CalkaMonteCarlo(f,a,b,n)
  2.  
  3. x=0;
  4.  
  5. for i=1:n
  6.     temp = a + (b-a)*rand;
  7.     x = x + f(temp);
  8. end
  9. y = (b-a) / n * x;
  10. end