Day 4 - 5

Date: 01/13/2020
Time: 12:00 PM - 3:00 PM
Location: Hostos Community College - A-534


Monte Carlo Methods

Here are some of important highlights of the wikipedia page:

Monte Carlo methods, or Monte Carlo experiments, are a class of algorithms that take a repeated random sampling to obtain numerical results.

. . .
In physics-related problems Monte Carlo methods are useful for simulating systems with many coupled degrees of freesome, such as fluids, disordered materials, strongly coupled solids and cellular structures.

. . .
In application to systems engineering problems (space, oil exploration, aircract design, etc.), Monte Carlo-based predictions of failure, cost overruns and scheduled overruns are routinely better than human intuition or alternative "soft" methods.
. . .
In principle, Monte Carlo methods can be used to solve any problem having a probabilistic interpretation. By the law of large numbers, integrals described by the expected value of some random variable can be approximated by taking the empirical mean (a.k.a. the sample mean) of indepedent sampels of the variable. When the probability distribution of variable is parametrized, mathematicians often use Markov chain Monte Carlo sampler.
. . .
In other problems, the objective is generating draws from a sequence of probability distributions satisfying a non-linear evolution equation.
. . .
Computer graphics
Path tracing, occasionally referred to as Monte Carlo ray tracing, renders a 3D scene by randomly tracing samples of possible light paths. Repeated sampling of any given pixel will eventually cause the average of the samples to converge on the correct solution of the rendering equation, making it one of the most physically accurate 3D graphics rendering methods in existence.
. . .
Artificial intelligence for games
Monte Carlo methods have been developed into a technique called the Monte-Carlo tree search that is useful for searching for the best move in a game. Possible moves are organized in a search tree and many random simulations are used to estimate the long-term potential of each move. A black box simulator represents the opponent's moves.

The net effect, over the course of many simulated games, is that the value of a node representing a move will go up or down, hopefully corresponding to whether or not that node represents a good move.

Monte Carlo tree search has been used to successfully to play games such as Go, Tantrix, Battleship, Havannah and Arimaa.

Coin Flip

Let's try to prove that the probability of landing on heads and tails are even: 50% using a uniform distribution. Using Monte Carlo Methods for this, is like taking a chain saw to cut a piece of bread, but since this is a Python boot camp, let's cut some bread.

In our specific case, we are going to use monte carlo experiments to prove some well known probabilities. One very simple example is that when a coin is flipped. There is a 50 percent chance that it will land on heads. If we flip a coin 10 times then, there might be a result of 9 heads and 1 tails. This seems to be different given our probability. However, if we perform the experiments N times where N is a very large number. It will converge to 50% heads and 50% tails, a very expected result.
Remember that the point of this is to practice how we can use loops and if statements to solve a problem in Python.
I won't be writing the code here we it will be very long. The code will be available on our official GitHub.

Monty Hall problem

Let's say you're on a game show and there are three doors in front of you. Behind one of the doors, there is 10 million dollars. Behind the other two doors, there is a penny. Here is how the rest of the game proceeds:

1. You are asked to pick a door.
2. The host opens a door that you didn't pick, revealing that there is nothing behind it.
3. You are asked if you would like to switch your original choice.

Would you switch doors? or stay? During the boot camp, we took a short vote with 15 students attending that day. The outcome? About 12 of the students to stay on the original choice, where as about 3 of the students chose to switch to the new one.

It turns out that if you were to switch you have a 2/3 chance of winning, where as you'd have a 1/3 probability of winning if you stayed on the same door. We can use Monte-Carlo Method to prove this as well. Other methods of proving this are Baye's Theorem, Direct calculation, and Strategic dominance solution.

For more information about the Monty-hall problem - Visit there wikipedia page here: https://en.wikipedia.org/wiki/Monty_Hall_problem

The code we used to prove this probability in class can be found on our official GitHub!