Difference between revisions of "Monte Carlo method in simulations"

From Simulace.info
Jump to: navigation, search
(Monte Carlo Set-Up for Simulations)
(Monte Carlo Simulation vs. Monte Carlo Sampling)
Line 32: Line 32:
 
== Monte Carlo Simulation vs. Monte Carlo Sampling ==
 
== Monte Carlo Simulation vs. Monte Carlo Sampling ==
  
 +
When using Monte Carlo methods, a distinction is often made between Monte Carlo simulations and Monte Carlo sampling. However, it must be mentioned that a clear distinction is often not or only hardly possible. Nevertheless, the following examples should give an insight about the differences.
  
 +
Monte Carlo Sampling
 +
The first example is the shortfall probability in wealth management. Let us consider an investor who, in t=0, divides his assets among n different assets. The number of different assets is hi. Thus, his wealth in t=0 is given by the function W0 .....
 +
 +
This portfolio is now held until time t = T. The price of the assets at time T depends on various risk factors such as inflation, the oil price or the general economic situation. Thus, the price at time T is determined by the following function, which takes these underlying factors into account:
 +
 +
 +
Let X be a random variable. The final value of the portfolio is then given by this function:
 +
 +
 +
Any number of observations can then be generated from this function using Monte Carlo. In this data set, it can then be evaluated how often a certain threshold was undercut.
 +
 +
 +
Monte Carlo Simulation
 +
A good example of a Monte Carlo simulation is a simple autoregressive process. This is used in economics, for example, to describe the evolution of a quantity of interest over time. This could look like this, for example:
 +
 +
Here X0 is given and et is a random variable. This is random for each point in time (t = 1,2,3...). This noise term consists of a sequence of mutually independent and identically distributed normal random variables.
 +
 +
In the first example, "Monte Carlo Sampling", the final value of X can be determined directly by the density function. In fact, no simulation is necessary. The PTi function is generated several times and then its properties are evaluated on the basis of the random experiments. In the second example, "Monte Carlo Simulation", a dynamic process is present. The value of Xt depends on its precursor Xt-1. The dynamic model in Monte Carlo is usually described by a discrete-time, a continuous-time or a discrete event model. This generates different paths. These examples suggest the definition that the term "sampling" is only used when no dynamics are generated over a time course, whereas this is exactly what happens with "simulations". In reality, however, these differences are often hardly to be made, since in both variants high-dimensional integrals of a function are often examined in order to make statements about a probability or expectation.
  
 
== Characteristics Of A High Quality Monte Carlo Simulation ==
 
== Characteristics Of A High Quality Monte Carlo Simulation ==

Revision as of 06:53, 24 January 2021

Introduction

Monte Carlo simulation is a mathematical technique used to simulate the possible outcomes of an uncertain event. Instead of fixed inputs, a probability distribution is used as a parameter at at least one point. By generating random probabilities as an input, a set of different outcomes and the probability of this outcomes can be generated through repeated simulation. The generation of random numbers by computers plays an important role in this.

The first well-known experiment that used randomness to solve a problem was "Buffon's Needle". The French scientist Georges Louis LeClerc, Comte de Buffon asked in the 18th century the question with what probability a randomly thrown needle intersects a grid of parallel lines. Only a few years later he was able to prove that this probability is 2L/Dπ (D > L). Let L be the length of the needle and D the distance between the lines. In his first experiments, LeClerc allegedly threw baguettes over his shoulder onto a tiled floor. In 1812, the French scientist Pierre-Simon Laplace suggested that this experiment could be used to determine the number π. In 1901, the scientist Mario Lazzarini was able to determine the number π to 6 decimal places by throwing needles on a grid of parallel lines, and that after only 3408 throws. However, this result is also doubted by scientists or also described as a stroke of luck. This is because in order to determine the number π to 6 decimal places in a 95% confidence interval, one would theoretically have to throw at least 134 trillion needles. Nowadays, these experiments can be simulated much faster and more efficiently with the help of computers. This is explained in detail in the chapter "Monte Carlo Simulation and the Number Pi".

The previous example of "Buffon's Needle" is based on actual chance by throwing a needle. Moreover, this experiment explored a deterministic problem that had already been solved analytically. Today's Monte Carlo simulations, however, approach the process in reverse. They serve as a tool when complex problems cannot be solved analytically. In addition, the simulations use artificially or computer-generated randomness. This was first used by John von Neumann and Stanislaw Ulam to explore the properties of neutron travel through radiation shielding. In doing so, they contributed to the invention of the atomic bomb during the Manhattan Project. They also gave the name to the Monte Carlo simulation, named after the famous casino in Monaco. Most of the Monte Carlo principles used today were developed during research into nuclear weapons.

Applications of the Monte Carlo Simulation

A Monte Carlo simulation can be used practically everywhere where randomness plays a role. Thus, there are no limits to the applications of Monte Carlo simulation. Therefore, the application areas range from particle physics to engineering, finance and climate research.

In climate research, for example, these simulations are used to determine the health risk of smog in cities for humans. There are different stochastic variables. For example, smog levels vary in different neighbourhoods of a city and people spend different amounts of time outside. In the simulations, these different variables are then randomly combined millions of times.

But Monte Carlo simulation can also be used in video games. Here it can help to create artificial intelligence. Using Monte Carlo tree search, the artificial intelligence can simulate all or at least many next possible steps and their consequences based on the starting point and choose the most promising next step on this basis.

However, these are only a few examples; the list could go on endlessly.

Monte Carlo Set-Up for Simulations

Since the application areas of Monte Carlo simulation are so broad, it is difficult to find a generally valid framework for a Monte Carlo set-up. Nevertheless, the principle that at least the majority of simulations follow should be explained here. First of all, the process we are looking for must be described and formulated in a model. For this, the inputs and outputs must be defined. Usually, a random variable X is sought. For this variable, the cumulative distribution function F(x) must be determined, for which F(x) = p[X <= x]. p must lie between 0 and 1. This results in x = F^-1(p). The inverse cumulative distribution function is therefore needed to calculate x. This curve is given for the common distributions in Excel, for example. Among others, the function for the standard normal distribution (=NORMSINV(probability)), the normal distribution (=NORM.INV(probability,mean,standard_dev)) but also the log normal distribution (=LOGNORM.INV(probability, mean, standard_dev)) can be used.

After the inverse has been determined, the Monte Carlo simulation usually follows 3 steps.

First, a random number for p is determined. As already written, this should lie between 0 and 1. In Excel, the function =rand() can be used for this. This random number is used as the input for F^-1.

Depending on the value p generated in the first step, F^-1 is determined.

The last step is to repeat steps 1 and 2 again and again until the desired or defined number of simulations is reached. According to the law of large numbers, one should obtain a data set that approximately reflects the true mean and true standard deviation of the population.

Monte Carlo Simulation vs. Monte Carlo Sampling

When using Monte Carlo methods, a distinction is often made between Monte Carlo simulations and Monte Carlo sampling. However, it must be mentioned that a clear distinction is often not or only hardly possible. Nevertheless, the following examples should give an insight about the differences.

Monte Carlo Sampling The first example is the shortfall probability in wealth management. Let us consider an investor who, in t=0, divides his assets among n different assets. The number of different assets is hi. Thus, his wealth in t=0 is given by the function W0 .....

This portfolio is now held until time t = T. The price of the assets at time T depends on various risk factors such as inflation, the oil price or the general economic situation. Thus, the price at time T is determined by the following function, which takes these underlying factors into account:


Let X be a random variable. The final value of the portfolio is then given by this function:


Any number of observations can then be generated from this function using Monte Carlo. In this data set, it can then be evaluated how often a certain threshold was undercut.


Monte Carlo Simulation A good example of a Monte Carlo simulation is a simple autoregressive process. This is used in economics, for example, to describe the evolution of a quantity of interest over time. This could look like this, for example:

Here X0 is given and et is a random variable. This is random for each point in time (t = 1,2,3...). This noise term consists of a sequence of mutually independent and identically distributed normal random variables.

In the first example, "Monte Carlo Sampling", the final value of X can be determined directly by the density function. In fact, no simulation is necessary. The PTi function is generated several times and then its properties are evaluated on the basis of the random experiments. In the second example, "Monte Carlo Simulation", a dynamic process is present. The value of Xt depends on its precursor Xt-1. The dynamic model in Monte Carlo is usually described by a discrete-time, a continuous-time or a discrete event model. This generates different paths. These examples suggest the definition that the term "sampling" is only used when no dynamics are generated over a time course, whereas this is exactly what happens with "simulations". In reality, however, these differences are often hardly to be made, since in both variants high-dimensional integrals of a function are often examined in order to make statements about a probability or expectation.

Characteristics Of A High Quality Monte Carlo Simulation

Problems with Monte Carlo Simulations

Examples of Monte Carlo Simulations for Students