Montecarlo method of pi calculation

Montecarlo method of pi calculation. No loops!!!
628 Downloads
Updated 11 Mar 2011

View License

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!!!

Cite As

Konstantin Ninidze (2024). Montecarlo method of pi calculation (https://www.mathworks.com/matlabcentral/fileexchange/30687-montecarlo-method-of-pi-calculation), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Fourier Analysis and Filtering in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.1.0.0

I have changed the title

1.0.0.0