Friday 8 July 2016

Simulation with Excel Series: Lab 1 Random Walk

Hello readers!

I'm starting a short series of basic simulations using MS Excel using this post. We will not enter any advanced topics in simulation, yet try to understand how some common problems can be simulated with a well-known tool.

Title: Random Walk (movement) of multiple particles (points) in 2D plain.

Initial Condition: a) No. of Particles = 100

                               b) Particles start to move from origin (0,0)

Basic Theory:
In this lab, we are trying to simulate the motion of particles in a 2D space for discrete time frames. As per our assumption, we have 100 particles, all of which start moving from (0,0) coordinates and move randomly. Hence, it has been called as “Random Walk”.

Procedure:
We perform our basic simulation in Microsoft Excel using the “Scatter Plot” feature. We achieve this by organizing the random data in a spreadsheet and applying formulae to the spreadsheet cells. In it, we employ a random function to generate a random (stochastic) sample of data for 100 particles in 11 discrete time frames (t0, t1… t11). For the initial state (t0), all the particles stay at (0,0) coordinates, and the next position of the particle is calculated using the formula:

X-position at last time + 1-2*RAND() and Y-position at last time + 1-2*RAND(), in which 1-2*RAND() gives us a value between -1 and 1.

Thus, the next position of the particle becomes unknown to us, and we can simulate random movement of the particles in 2D space. Finally, we can see the results by selecting the data for one particular time, clicking the “Insert” menu and selecting “Scatter”.   
The sample data for 4 particles is tabulated in next section (as showing 100 becomes very long).

Sample Data:
Table1: Sample Data for 4 particles for 4 discrete time frames.
Time = 0
Time = 1
Time = 2
Time = 3
X
Y
X
Y
X
Y
X
Y
Particle1
0
0
0.230713
0.414474
0.197587
0.397396
0.705377
-0.43751
Particle2
0
0
-0.97556
-0.74393
-1.06599
-0.3071
-0.95934
-0.72553
Particle3
0
0
0.530602
0.295072
0.233677
-0.53365
-0.74835
-0.83489
Particle4
0
0
-0.57715
0.912138
0.028148
1.523969
-0.1651
1.801373

Output:
Below are the scatter plots for four different time frames. We can clearly see the randomness in the plotted data.





No comments:

Post a Comment

Was this post helpful? Ask any questions you have, I will try to answer them for you.