Saturday, May 12, 2012

Monte-Carlo crude integration using Matlab

monte_carlo_crude_int
% ========================================================================
%**** To do integration of x with limit 0 to 1 by Monte-Carlo crude *****
%********************** integration method *******************************
%************************* By Mahesha MG *********************************
% Date: 02/02/2013
% ========================================================================
n=10000;
r=rand(1,n);
s=sum(r);
display('Integration of x is')
s/n
% ========================================================================
Integration of x is

ans =

    0.5029

1 comment: