Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

HELP PLEASE MATLAB ASSIGNMENT!!! URGENT !! please answer Q2a - Q2b and also write the codes clearly :) thanks ! QUESTION 2 3 MARKS Background

HELP PLEASE MATLAB ASSIGNMENT!!!

URGENT !!

please answer Q2a - Q2b and also write the codes clearly :)

thanks !

image text in transcribedimage text in transcribed

QUESTION 2 3 MARKS Background Monte Carlo methods are a broad class of computational algorithms that rely on repeated random sampling to obtain numerical results. You have been asked to estimate the value of t using the Monte Carlo method. A number of randomised points is generated within the box of unit width, as shown in figure 2. Some of the points lie within the circle, while others lie outside the circle. The value of is calculated using the following expression 4N where Nc represents the number of points inside the unit circle, and Ns is the number of dots within the square. In figure 1, there are 17 points inside the circle and 20 points inside the square (i.e. 3 points outside the circle). Therefore, 3.4. This estimated value of should become more accurate with an increasing number of points. 4x17 20 Figure 2: Randomised points generated inside a box containing a unit circle The procedure to perform the Monte Carlo method is listed below: 1. 2. 3. Generate a randomised point within a square containing a circle of unit radius Determine Nc and Ns, and calculate the estimate of Repeat steps 1 and 2 for a specified number of points Complete the following tasks to perform the Monte Carlo procedure described above Q2a In the Q2a.m file, generate a 2x1 subplot arrangement where the top panel contains a circle of unit radius and a square with a width of 2 units, both centred at (x,y) (0,0) (see figure 3 for an example). Plot these shapes as black lines and set the axes to be square (option for axis). Details of the bottom panel are described in 02b. Q2 In the Q2b.m file, prompt the user for a specified number of points to estimate rt using the input() function. Generate your first randomised point by randomising its x and y-coordinates. The limits for the x and y- coordinates should be limited to the bounds of the square (i.e. from -1 to 1 in both directions). Plot this randomised point in the top panel of the figure as a red dot if it lies on or within the circle, or as a blue dot if it is outside the circle. Use a marker size of 15. After plotting your first randomised point, calculate the estimate of n and plot the result as a black dot in the bottom panel of the figure (see figure 3). The current estimate value of rt should be stated in the title 0.5 0.5 -1 Estimate of pi 4.000000 4.5 0 02 04 06 08 112 141 18 Figure 3: Plot after the 1st randomised point. Repeat the above instructions until the number of specified points is reached. Update the top and bottom panels after each new point is created and pause for 0.1 seconds using the pause) function to create an animated effect. i.e. your top and bottom panels should populate with points over time (see figure 4 for examples) Snapshots of the figure after the 3rd and 100th randomised points are shown in figure 4 *You should have five figure windows by the end of this task. 0.5 05 Estimate of pi 2.666667 Estimate of pi 3.280000 3.5 3.5 25 25 1 12 1416 18 222 24 26 283 10 230 40 5070 80 100 Figure 4: (Left) Plot after the 3rd randomised point. (Right) Plot after the 100th randomised point

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

Describe the nature of the two forms of an income statement.

Answered: 1 week ago