馃攳
Monte Carlo Simulation - YouTube
Channel: MarbleScience
[0]
Hi and welcome to a video about Monte
Carlo simulations,
[4]
a type of simulation that i really enjoy
because
[7]
it's a super simple concept and it still
allows to solve
[11]
incredibly complex problems. So after
watching this video you will know
[15]
exactly what Monte Carlo simulations are
and what types of problems you can solve
[20]
with them.
So what are Monte Carlo simulations? Well
[24]
the name Monte Carlo actually refers to
the
[27]
city in Monaco which is known for its
casinos and gambling,
[31]
and in the context of simulations "Monte
Carlo" is basically used as a synonym for
[37]
randomness, like the randomness in
gambling.
[40]
So, Monte Carlo simulations are
simulations evolving
[44]
randomly, and this might seem
counterintuitive at first because
[49]
how can something useful come out of a
randomly evolving simulation?
[54]
but we will see why randomness can be
actually very useful in a simulation in
[58]
just a moment.
So let's take a look at the first
[61]
example.
In the simulation we have a sort of
[65]
marble dropping device
that moves around randomly above this
[69]
rectangular table
and drops marbles, and on the table there
[73]
are two bowls
one with a square cross section and one
[77]
with a circular cross section,
and each of these bowls is placed on
[82]
some sort of scale
which displays how many marbles are in
[86]
each bowl
at this time, and if we let the
[89]
simulation evolve for a while
[94]
and then divide the number of marbles in
the circular bowl
[98]
by the number of marbles in the square
bowl the result happens to be
[103]
roughly pi. Without any advanced math
knowledge,
[107]
simply by randomly dropping marbles into
two bowls,
[111]
we can estimate pi. Okay so let's unpack
what happened in this simple example of
[116]
a Monte Carlo simulation.
When we drop a marble in a uniformly
[121]
random location
then the probability for this marble to
[125]
end up in one of the bowls
is proportional to the bowls
[128]
cross-section area,
and if we repeat this process over and
[133]
over again
then also the number of marbles ending
[136]
up in this bowl
will be proportional to the bowl's
[139]
cross-section area.
The area of the square bowl in this
[143]
example is
its edge length a squared and the area
[147]
of the circular bowl is
pi times a squared, and that's how we get
[152]
pi
as the fraction of the two areas and
[154]
consequently as
the fraction of marbles in each bowl.
[159]
So in this example of a monte carlo
simulation, we essentially determine an
[163]
area by taking random samples.
With each random sample we probe whether
[169]
this specific location is
inside or outside of some area, and by
[174]
taking enough samples
we get a good idea of how big an area is.
[180]
This idea of obtaining random samples
is probably quite familiar to you if you
[186]
think about how
real world studies are designed. Let's
[190]
say we wanted to find out
the average height of all people
[194]
worldwide.
Then, in principle we would need to
[197]
measure the height of
each person worldwide, and then take the
[201]
average to get an accurate result,
but of course we can't go out and
[205]
measure the height of billions of people.
So what can we do? Well we can measure
[211]
the height of
some smaller group of people, and hope
[214]
that their average height
is a good estimate for the average
[219]
height of all people worldwide,
but there are two things that we need to
[223]
consider. Firstly
the selection of the group of people
[227]
needs to be
unbiased. We can't just measure the
[230]
height of the next five people we meet
as we might live in an area with
[235]
especially tall or short people.
A better way to get an unbiased sample
[240]
group
would be to randomly select people
[243]
worldwide.
Randomness helps us to make an unbiased
[247]
selection.
Secondly, the group of measured
[251]
people must not be
too small. If we only measure the height
[255]
of let's say
five people we might have just
[257]
coincidentally picked five taller or
shorter people,
[261]
and we can be more and more confident
about the average height
[265]
the more people we measure. In
probability theory this is called
[269]
the "law of large numbers" which
essentially states that
[273]
an average tends to come closer to its
expected value
[277]
the more samples we have, and the exact
same is also true for Monte Carlo
[282]
simulations. The core idea of a Monte
Carlo simulation is that we can
[286]
get an unbiased, representative group of
samples
[290]
from some large ocean of possibilities
if we allow the simulation to evolve
[295]
randomly. In the marble dropping example,
in principle we would need to test for
[301]
every possible location
whether a marble ends up inside or
[305]
outside the bowl
to determine the bowl's cross-section
[309]
area precisely,
just like we in principle would need to
[313]
measure the height of each person
worldwide
[316]
to determine the average height
accurately.
[320]
Instead, we can rely on randomly
selected samples, and according to the
[325]
law of large numbers
we can be more and more confident about
[329]
the result
the more samples we take. We can see this
[333]
if we plot
the fraction of marbles in both bowls
[337]
over time.
Initially, the value is fluctuating
[340]
heavily,
but with more and more samples generated
[344]
by the randomly evolving simulation,
the fluctuations become smaller and
[349]
smaller, and we can see that
the fraction approaches the expected
[353]
value
pi
[357]
Now I hope that using a Monte Carlo
simulation to determine pi
[361]
was an illustrative example, but it's
certainly not really relevant,
[366]
but actually this animation of dropping
marbles
[369]
has a second example of a monte carlo
simulation somewhat
[373]
hidden in it. So let's take a look at
this hidden more relevant example of a
[378]
Monte Carlo simulation in the last part
of this video.
[382]
Rendering such animations or the simpler
example scene
[386]
is all about simulating the flow of
light, and to get an accurate image you
[391]
need to find out
how much light hits different areas of
[395]
the scene.
This is not an easy task if you
[398]
consider that
diffuse surfaces can scatter light in
[402]
virtually any direction.
So let's say we want to find out how
[406]
much light hits
this marked area. Then, in principle we
[410]
would need to evaluate
all possible light paths to find out
[414]
which fraction of them
ends up in the marked area. Now clearly
[419]
it's
impossible to follow all the possible
[422]
light paths.
So what can we do if we can't follow all
[426]
possible paths?
Well I hope that after watching the
[430]
video to this point,
the answer is quite obvious. If we can't
[434]
simulate
all possible light paths then the best
[438]
we can do is to
simulate a representative group of
[442]
sample paths, and what is a good way to
get an
[446]
unbiased representative group of samples?
We can employ randomness! So
[452]
whenever we hit a diffuse surface we
simply pick,
[456]
randomly, one of the infinitely many
directions
[459]
in which the light could be scattered.
One randomly simulated light path on its
[464]
own
is not valuable, but if we generate many
[467]
sample paths
then we get a good idea of the
[471]
illumination of the scene.
We will see areas that are hit by many
[475]
of the randomly generated light rays
(brighter areas) and we'll see other areas
[481]
that are hit only by few of the randomly
generated rays
[485]
(darker areas). Actually if you think about
it,
[488]
counting the number of randomly
generated light rays
[492]
hitting some area is really not that
different from
[495]
counting the number of randomly dropped
marbles
[498]
hitting some bowl, and in this marble
dropping
[502]
attempt to determine pi we saw that the
result gets more
[506]
accurate the more samples we take, and
the same is also true for
[511]
Monte Carlo path tracing. These four
images
[514]
show the same scene rendered with a
different number of
[518]
randomly simulated light paths. We
can clearly see
[522]
that with more sampled paths the result
becomes
[526]
more accurate, leading to a less noisy
image.
[531]
Okay so let's wrap this up. A Monte Carlo
simulation is a randomly evolving
[535]
simulation,
and in this video we have looked at two
[538]
examples how such a randomly evolving
simulation can be useful. We have
[543]
determined pi by randomly dropping
marbles into bowls,
[546]
and we have simulated the flow of light
by generating random light paths.
[551]
Both these examples and many other
examples where
[556]
Monte Carlo simulations are useful, they
have one thing in common.
[560]
They involve an unfeasibly large number
of possibilities,
[564]
and instead of trying to go through all
these possibilities,
[568]
with monte carlo simulations we
deliberately only explore
[572]
a random subset of them, and according to
the law of large numbers we can still
[578]
get away with these random samples
if we only gather enough of them.
[583]
Okay so that's it for this video.
I hope you found it useful. If you did,
[587]
please leave a like
and maybe subscribe and i hope to see
[591]
you in the next video! Bye.
[605]
you
Most Recent Videos:
You can go back to the homepage right here: Homepage





