Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Newton's method wikipedia , lookup
Simulated annealing wikipedia , lookup
Mean field particle methods wikipedia , lookup
Monte Carlo methods for electron transport wikipedia , lookup
Root-finding algorithm wikipedia , lookup
False position method wikipedia , lookup
Monte Carlo Simulation: Area of a shape Abstract This report describes the application of Monte Carlo Simulation to solve a simple problem which is to find area under the curve. Monte Carlo methods are often used in simulating physical and mathematical systems. The idea of using Monte Carlo method is Geometrical Method For the geographical method we will divide the shaded region into two parts, then calculate areas of these then add them to get area of whole shaded region. π1 = ππππ ππ ππππ‘πππππ(1 β€ π₯ β€ 5 & 0 β€ π¦ β€ 1 π2 = ππππ ππ π‘πππππππ(2 β€ π₯ β€ 4 & 1 β€ π¦ β€ 2) Area of shaded region = r1 + r2 by generating random points, then finding their = (4 β 1) + ( probability to lie within the targeted region. It is =5 observed that the larger the random point, the 2β1 ) 2 Analytical Method greater the accuracy of the simulated result. Area of shaded region 2 Introduction = β« 1ππ₯ The problem to be solved is shown in figure 1. The 1 3 area of the shaded region is to calculate. 1, π₯ β 1, π(π₯) = { βπ₯ + 5, 1, + β«(π₯ β 1)ππ₯ 2 4 1β€π₯β€2 2β€π₯β€3 3β€π₯β€4 4β€π₯β€5 + β«(βπ₯ + 5)ππ₯ + β« 1ππ₯ 3 2 y=1 1.5 Numerical Method y=1 1 0.5 0 0 1 2 3 4 5 6 x Figure 1 We will solve this problem using three methods. i. ii. iii. 4 = π₯|12 + (π₯ β 1)|32 + (βπ₯ + 5)|43 + π₯|54 = 2 + 1.5 + 1.5 + 2 =5 2.5 y 5 Geographical Method Analytical Method Numerical Method To find area of the shaded region, we will simulate this by monte carlo method in matlab. . N uniform random points are generated for x and y coordinates of the shaded region and the probability of random numbers βnβ falling inside the three shaded regions (i.e. Region 1, Region 2,Region 3 and Region 4) is found that is used to calculate the area of the entire shaded region. A series of uniformly distributed random points, starting from 100 up to 1000000, is generated and it is observed that the accuracy of the area calculated increases as the random points are increased. The ratio n/N is used to calculate the area of the entire shaded region as follows: Uniform random numbers generated = N Random numbers falling in shaded region= n Area of entire rectangle= 4*2=8 Area of shaded region = (n / N)*8 The random points, under the curve shown in blue color and in red color above the curve in the figure. The curve is in black color. Figure 3 The error is also plotted as a function of random numbers in figure 4.The figure shows that as the random numbers increase the error will decrease. Figure 2 We can see random points for every iteration in the matlab. But we have a large number of iterations per 1 random number. So there are many figure as we have one figure per 1 random number. Eventually we put a condition for plotting the random number that figure is only for highest random number. The simulated result and the actual result is plotted as a function of random numbers in figure 3.It is proved from the figure that as the random numbers increases the simulated result is going close to the actual result. Figure 4 Conclusion It is observed that the simulation results represent an excellent approximation of the analytical results as long as the uniformly distributed random points are large in number.