2.0

2.0 | 2 ratings Rate this file 4 Downloads (last 30 days) File Size: 1.5 KB File ID: #30687

Montecarlo method of pi calculation

by Konstantin Ninidze

 

08 Mar 2011 (Updated 11 Mar 2011)

Montecarlo method of pi calculation. No loops!!!

| Watch this File

File Information
Description

A circle of radius 0.5 is inscribed inside a square with side length 1.
Script picks N points at random inside the square. It then checks to see if the point is inside the circle and then generates a figure in which the points ''in'' and ''out'' are plotted in different colors. Say we have M points inside the circle. Pi is then approximated as follows:
% Pi = 4*M/N.
No loops!!!

MATLAB release MATLAB 7.11 (2010b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
09 Mar 2011 Sean de

-Malware script.
-Does do exactly what it says it does though and has a decent description.
-For educational purposes the direct calculation of the distance from the point to the center of the circle is better than using inpolygon (and probably more accurate).
-The 'MY' in the title makes it unnecessarily long.

10 Mar 2011 Anon

Please provide a proper title for your function. "Dr., professor" is a joke!

Please login to add a comment or rating.
Updates
11 Mar 2011

I have changed the title

Tag Activity for this File
Tag Applied By Date/Time
mathematics Konstantin Ninidze 09 Mar 2011 10:21:51
simulation Konstantin Ninidze 09 Mar 2011 10:21:51
mathematics Antonio 18 Apr 2012 11:14:58
simulation Antonio 18 Apr 2012 11:15:02

Contact us at files@mathworks.com