Download Monte Carlo Simulation: Area of a shape Abstract This report

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

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 method wikipedia , lookup

Fisher–Yates shuffle wikipedia , lookup

Transcript
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.