LECTRUE 1.2: DART GAME

Once we have specified the INPUT and the logic, we can run the simulation to see the outcomes. The OUTPUT is the measurements of the outcomes. For example, the mean profit and its 95 percent confidence internal. Typically it involves statistic analysis. Taking together, we have
OUPUT = logic (INPUT).

To illustrate, we consider a dart game. Kobe is to play the dart game with his friend. The board is of two by two size, with the circle of radius one. Kobe is a lousy shooter. He can make each shot on the square board, beyond that his shots are random. His friend makes a generous offer: Kobe gets free beer if he hits in the circle. So what is the probability p that Kobe gets free bee?

There are several ways to solve this problem. For example, since Kobe shots uniformly on the dart board, his chance of hitting the board is one. Given that, his chance of hitting in the circle would equal the ratio between the circle area and the board area: p= \frac{\pi r^2}{2\times 2} = \pi/4.

This approach requires the knowledge of the circle area formula and the value of pi. If you don’t, you can still figure out through experiments, e.g., by asking Kobe to shot. For example, If Kobe shots N=100 times, and you can count the number n of times he hits in the circle. Then p= \frac{n}{N}.

When the sample size N is large, it may be too costly or even infeasible to do real experiments. Instead, we can carry out on computer. We focus on a quarter of the board. First, specify the INPUT. In this case, we know there is only one random variable, the shot (X,Y)\in [0,1]^2, and X, Y\sim [0,1]. In Excel: RAND().

Next, we figure out the logic. For each shot (X,Y), we need to know whether it is a hit. That is, h= IF( d <1, 1, 0), where d = \sqrt{ X^2 + Y^2} is the distance between the shot (X,Y) and the center (0,0). So h is an indicator. In Excel: h= IF( sqrt( X^2 + Y^2 )<1, 1, 0), or simply h= 1*( sqrt( X^2 + Y^2 )<1).

To generate a sample, we replicate N=1000 shots. For each shot (X_i,Y_i), we know whether it is a hit, h_i =1 or 0. We then do statistic analysis. The total number of hits is \sum_{i=1}^N h_i, and the probability p= \frac{ \sum_{i=1}^N h_i }{N}.

 

IMG_7087

Advertisements
LECTRUE 1.2: DART GAME

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s