Social Icons

Sunday, 4 May 2014

Monte Carlo Simulation

N=input('enter no of dats');
r=4;
c=0;
for i=1:N
    x=r*rand(1);
    y=r*rand(1);
    if((x^2+y^2)<=r^2)
        c=c+1;
       
    end;
end;
n=c;
pi=(4*n)/N

No comments:

Post a Comment

 

Sample Text

Sample text

 
Just Programming Cse DriveReputation Management