Вы находитесь на странице: 1из 2

MONTE CARLO METHOD

This program estimates the value of pi by using monte carlo


method. Monte carlo simulation uses random numbers to
examine systems(in chemistry, physics, economics..)That are
too large and complicated to observe and reason about
directly.

Montie carlo computation vs stochastic simulation

Some people use the term Monte carlo method to mean any
computation that involves random numbers . However, a more
generally accepted meaning of Monte carlo is restricted only to
those computations in which random numbers are used to
obtain solutions of problems which are inherently deterministic.
And for those computations that employ random numbers to
solve inherently stochastic problems the term ‘ stochastic
simulation’ is used. For example, the inventory problem would
be a case of stochastic simulation and not monte carlo. But the
following method of evaluating the constant pi by making use
of random numberswould be called a Montie carlo method.

The method uses the following steps to obtain the solution

 Define a domain of possible inputs.

 Generate inputs randomly from the domain using a certain


specified probability distribution.

 Perform a deterministic computation using the inputs.

 Aggregate the results of the individual computations into


the final result.

Here we consider a less sophisticated application: estimating


the value of pi. First consider a circle of unit radius inscribed in
a square. The area of the circle is pi, but let us zoom in on the
first quadrant. Now imagine throwing a dart at random into this
square. The probability that it hits the grey region is pi/4(since
that is the area of the grey region, and the square has unit
area). So if you throw n darts at random and keep track of the
number of hits h in the grey region, you would expect to get
h=pi*n/4. Thus we can estimate pi by performing this
experiment and observing the actual value of h. Throwing a
dart at random into the unit square amounts to choosing two
values x and y from the interval[0,1]. Check that the point(x,y)
is in the grey region by computing its distance from the origin.
If the distance is less than or equal to 1 the point lies inside the
grey region that counts for a hit, otherwise it is a miss.

No. of darts hitting shaded region


area of shaded region
=

No. of darts hitting inside square


area of square

No. of darts hitting shaded region


¼
=

No. of darts hitting inside square

Or

4 * No. of darts hitting shaded region


No. of darts hitting inside square

Вам также может понравиться