If we have N discrete time steps, we can evenly distribute them in the space between 0 and 1. It implies that we assign one slot to each discrete time step. For instance, if N=10 then to each discrete time step we can assign the following slots {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9}.

If we start increasing N, the slots will start getting closer and closer to each other, thus creating a continuum. Additionally, we can normalize the values associated with those slots by the square root of N. Formally, if we have a simple random walk defined as:

Simple Random Walk Definition

then a continuous and normalized process is defined as:

Continuous Random Walk [1][2]

We demonstrated how with a simple trick we can switch from discrete to continuous notation. Now, letting N to approach infinity leads us to the definition of a Brownian Motion.

Brownian Motion Definition

If we let N to grow indefinitely, or to be sufficiently large, we observe some interesting properties of the above mentioned random process. From the Central Limit Theorem, we know for sure that only when t = 1:

Converging to a Normal Distribution

i.e. it converges to a standard normal distribution with mean 0 and variance 1. However, the Central Limit Theorem does not give us an answer for the distribution of all other points, i.e. for arbitrary t. The answer is given by the Donsker’s Invariance Principle which extends the Central Limit Theorem such that for any t in [0, 1] we have:

Donsker’s Theorem [1][2]

It signifies that the process converges to a standard Brownian Motion, which has the following properties:

The initial value is zero;

W has independent increments;

W has Gaussian increments and

W is continuous in t.

In this case, just for demonstration purposes to show how to construct a Brownian Motion from a random walk we used the unit increments {-1, +1} with an equal probability to occur. More generally, these increments can be generated from any distribution, most frequently the normal distribution. This is true due to the universality of the Central Limit Theorem as well as the Donsker’s Invariance Principle.

Once we know the definition of a Brownian Motion, we can implement a simulation in Python and make a visualization of the possible outcomes.

Brownian Motion in Python

We can easily construct a Brownian Motion using the NumPy package. By providing the number of discrete time steps N, the number of continuous-time steps T, we simply generate N increments from the normal distribution with some variance h and distribute them across the continuous-time steps T. Then, the Brownian Motion is a cumulative sum of the increments, i.e. we use the cumsum function. The Python code is given below:

Animating the Brownian Motion

Serving nicely formatted static plots is cool, but it doesn’t put the accent on what is important to tell. For this reason, we use an animated plot, animating the principal point which is aligned with the message we want to send.

To send the correct message, in this case, we illustrate the universal truth of the Donsker’s Invariance Principle. As the number of discrete time steps N grows, the simple random walk approaches the standard Brownian Motion. We realize this using the Matplotlib’s animation API, as shown in the code below:

The animation function needs three essential inputs: i) an instance of the figure to show the animation, ii) data initialization function and iii) a function that defines the animation logic. Additionally, we provide the number of frames to draw and the delay in milliseconds between them.

The animate function plays a central role. Every iteration, we generate from scratch a Brownian Motion with 10 more steps compared to the one in the previous iteration. Thus, the result we get is the following: