Question: This MATLAB Code will produce a simple Monte Carlo simulation that estimates the value of (i.e., the ratio of the circumference of a circle to

This MATLAB Code will produce a simple Monte Carlo simulation that estimates the value of (i.e., the ratio of the circumference of a circle to the circles diameter) following the derivation by Georges-Louis Leclerc, Comte de Buffon. The accuracy of the estimate will be dependent on the number of experiments.

The following list gives requirements for the code. Note that an experiment is considered one (1) drop of a needle, while a trial is considered a set of experiments. This list should provide your a clear path toward creating a flow chart.

One m-file called buffon.m.

Explicitly required: header comment describing the program and giving overview of use/syntax to run it.

Explicitly required: in-line comments describing the purpose of any non-trivial code.

Explicitly required: comment block containing description of each variable parameter and its physical significance.

A function called needle drop, (saved as needle drop.m) which will perform a single ex- periment. In other words, it will randomly drop a single needle and check to see if it crosses the nearest grid line and return the needle endpoints along with some identifier for the crossing.

A for-loop around the function for completing a set number of separate experiments (i.e. 1 trial).

A for-loop around the experiment loop for completing a set number of separate trials.

A random number generation using rand (2-numbers) to determine the physical location of the center of mass of the needle on a cartesian coordinate system for each experiment.

A random number generation using rand (1-number) to determine the angle of the needle relative to a horizontal line perpendicular to the vertical separations for each experiment.

1

An estimate for based on the formula estimate of Buffons needle problem.

Well formatted plots with the following information.

Figure 1: a scatter plot representation of the ability of the function rand to provide an unbiased input using the data associated with the angle of the needle. This plot should show the angle as a function of the experiment for a given trial.

Figure 2: a cartoon representation (MATLAB-generated plot) of the distribution of needles for one (1) trial plotted on a square containing marked vertical separations, where needles crossing the vertical separations are distinguishable from those needles that do not. This plot should represent the needles as lines of different colors depending on whether they do or do not cross a vertical separating line, and the plot should also show the vertical separating lines on the square playing field.

A formatted output from the script stating the overall estimate for the value of along with standard deviation (i.e., The average value of pi is 3.1426E+00 plus or minus 1.0E-03 after 1E+04 trials of 1E+03 experiments.).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!