## Posts Tagged ‘**brownian motion**’

## Fluctuations of the time-weighted average price

Motivated by an interview question posed to a friend of mine recently, today I’d like to talk about the **time-weighted average price** (**TWAP**) of a financial asset (e.g. a stock).

Let’s consider the **price **of our stock a short time scale (e.g. **intraday**) corresponding to the interval . Its price will start at and evolve through to ; the time-weighted average price is

defined in this way is interesting, since this is the **effective price** obtained when executing a large order in the market by splitting it into smaller chunks and executing them throughout the day at a constant rate. This TWAP algorithm is one of the basic algorithmic execution tools used e.g. by asset managers to minimize market impact costs. More sophisticated ones include volume-weighted average price (VWAP) where one would adjust the volume executed at each time during the day proportionally to the typical trading volume at that time.

With this motivation, let us look at the **statistics of the TWAP** , and especially its fluctuations. Usually, one approximates the logarithm of the stock price by a brownian motion (corresponding to the assumption, that *relative* price changes are independent and identically distributed). However, on small time scales (when fluctuations are small), the compounding effect is negligible. For simplicity, I will hence assume that is a brownian motion with drift and variance . This means that *absolute* price changes are i.i.d..

## Moments of the TWAP

The Gaussian process is fully determined by its first two moments,

From this, we obtain the first moments of the TWAP (for simplicity I subtracted the trivial component):

In other words, the **variance of the TWAP relates to the variance of the intraday stock price change** as

( denotes connected expectation values here).

This procedure can easily be continued to calculate higher moments of the TWAP in terms of and . In fact, given that the linear combination of Gaussians is again a Gaussian, we can directly infer that the TWAP has a Gaussian distribution with mean and variance .

## Distribution of the TWAP via the MSR formalism

There is another way to obtain the full distribution of the TWAP directly, via the Martin-Siggia-Rose formalism. Using the MSR approach, we know that the generating function of any linear functional of the Brownian is

where is the solution of

,

Applying this to a constant , we get . From this follows the **generating function of the TWAP **

This is clearly the generating function of a Gaussian distribution with the same moments as computed above.

## Stochastic Logistic Growth

A classic model for the growth of a population with a finite carrying capacity is **logistic growth**. It is usually formulated as a differential equation,

. (1)

Here is the size of the population at time , is the **growth rate** and is the **carrying capacity**.

The dynamics of eq. (1) is **deterministic**: The initial population grows (or decays) towards the constant carrying capacity , which is a fixed point of eq. (1). This is seen in the solid trajectories in the figure below:

To make this model more realistic, let’s see how we can extend it to include **stochastic fluctuations **(semi-transparent trajectories in the figure above). I’ll look in the following at a simple stochastic logistic growth model (motivated by some discussions with a friend), where the **steady state can be calculated exactly**. The effect of stochasticity on the steady state is twofold:

- The population size for long times is not fixed, but fluctuates on a scale around the carrying capacity.
- The average population size is increased above the carrying capacity , but the shift goes to 0 as increases (i.e. the deterministic model is recovered for large ).

Now let’s look at the calculation in detail…

## A stochastic, individual-based logistic growth model

In eq. (1), the population is described by a real-valued function . In reality, populations consist of **discrete individuals** and the population size doesn’t change continuously. So, a more realistic approach is to describe the population dynamics as a **birth-death process** with the following reactions:

(2)

In other words, we assume that during a time interval two events may happen:

**Birth**: With a probability , any individual may give birth to offspring, thus increasing the population size by 1.**Death due to competition**: With a probability , out of any two individuals one may die due to the competition for common resources. Thus the population size decreases by 1. Note that is related to the carrying capacity in eq. (1) by .

Note that the stochasticity in this model is not due to random external influences but due to the discreteness of the population (**demographic noise**).

## Solution of the stochastic model

The system of reaction equations (2) translates into the following **master equation** for the probabilities of the population size at time being equal to :

(3)

This looks daunting. However, it can be simplified a lot by introducing the **generating function**

After some algebra we obtain

.

This looks simpler than eq. (3) but still finding the full time-dependent solution does not seem feasible. Let’s focus on the **steady state** where . Together with the boundary conditions and , we obtain the steady-state solution

. (4)

Here we set to connect to the notation of eq. (1). Correspondingly, the steady-state probabilities for population size are

. (5)

Of course, these can equivalently also be obtained by solving the recursion relation (3) with . This result can be easily checked against simulations, see figure below.

## Steady state with stochasticity

Let’s try to understand what the steady state of our stochastic model looks like. From eq. (4) we easily obtain the first moments of the distribution of the population size. The **mean population size** is:

So for large carrying capacities , we recover the same result as in the deterministic model (which is reasonable since for large population sizes demographic noise is less pronounced!). However, for smaller **fluctuations increase the average population size**. E.g. for , the average population size in our stochastic model is .

Now let us look at the **variance**,

.

For large , we have . So we see that stochastic fluctuations **spread out the steady state **to a width around the carrying capacity.

## How does an absorbing boundary modify the propagator of a stochastic process?

A recurring theme throughout my blog are stochastic processes, widely used to model quantities under the influence of both deterministic evolution laws and random fluctuations. A complete solution for a stochastic process is its *propagator*: The probability density for the final state at some time given an initial condition at time . The propagator depends on the boundary conditions imposed on the stochastic process. For example, an absorbing boundary is useful for describing extinction in a stochastic model of population dynamics: When the population of a given species reaches zero, it cannot be re-introduced.

Typically, however, the “free” propagator for a stochastic process — i.e. the propagator without any boundaries — is much easier to determine than the propagator with any given boundary condition.

However, common sense tells us that the free propagator for a stochastic process contains already all there is to know about it. So I have wondered for quite a while if and how one can recover e.g. the propagator with an absorbing boundary, knowing only the free propagator. I found the solution only quite recently in this preprint on arXiv, and think that it is interesting enough to explain it here briefly.

## The result

Consider a one-dimensional, stationary, Markovian stochastic process. Let us denote its *free propagator* by

This is the density for the final value at time , given an initial value at time . Stationarity of the process implies that is a function of the time difference only. Define the Laplace transform of the free propagator by

Now let us add an absorbing boundary at . Then, the propagator

is the density for the final value at time , given an initial value at time , *without touching the line between and *. **The upshot of this post is the following simple relationship between the Laplace transforms of the free propagator and of the propagator with absorbing boundary :**

(1)

In case the denominator on the right-hand side is zero, one may have to perform some limiting procedure in order to make sense of this formula. We can now check how nicely it works for simple cases, like Brownian motion with drift, where the result is known by other means.

## Example: Brownian motion with drift

Let us consider an example, the Brownian motion with drift . Its stochastic differential equation is

where is white noise with .

The free propagator is a simple Gaussian

Its Laplace transform is given by:

To compute , let us assume , . Note this is without loss of generality, since if and are on opposite sides of the absorbing boundary the propagator is zero. Applying the result (1), we have

The inverse Laplace transform of this expression is:

This is, of course, exactly the same result (the so-called **Bachelier-Levy formula**) which I had already discussed earlier in a guest blog post at Ricardo’s blog, using slightly different methods (a variant of the Cameron-Martin-Girsanov theorem). Note that some signs which were wrong in the original post are corrected here.

## The proof

Now let us go back to the case of a general stochastic process, and discuss how formula (1) can be proven. Let us assume that the stochastic process in question has a path-integral representation, i.e. that

for some action .

Now, to add an absorbing boundary at we weigh each crossing of by a factor in the path integral, and then let . This effectively retains only those trajectories in the path integral, which never touch . We thus have:

.

Now, to evaluate the path integral, we expand it in a series in (or, in other words, in the number of crossings of ). We get:

.

Note that here I cancelled the factor , coming from the Taylor expansion of , against the possibilities of ordering the times . This is why I can assume them to be in ascending order above. Also, the functions actually set all .

Taking Laplace transforms, the time integrals (which are a -fold convolution) simplify to a simple product:

.

Now, one easily obtains the claimed result:

.

This computation can, of course, be generalized to more complicated situations like several boundaries, higher dimensions, etc. For details see again the original preprint by C. Grosche. Have fun and let me know if you have questions!

## A quick introduction to the Martin-Siggia-Rose formalism

**The Martin-Siggia-Rose (MSR) formalism is a method to write stochastic differential equations (SDEs) as a field theory formulated using path integrals.** These are familiar from many branches of physics, and are simple to treat perturbatively (or, in some cases, even to solve exactly).

We start from an SDE of the form:

,

where is a deterministic function and is Gaussian noise with an arbitrary correlation function :

.

MSR recognized that observables, averaged over solutions of this SDE, can be written as a path integral with a certain action:

,

where

.

A useful **special case** is an automonous (time-independent) SDE with **multiplicative noise**:

,

where is Gaussian white noise. The resulting action for the path integral is local in time:

.

I will now show a few concrete examples, and then explain how this mapping is derived.

## Example: Ornstein-Uhlenbeck process

The Ornstein-Uhlenbeck process is one of the few stochastic processes treatable analytically. Its SDE is:

,

where (else the process blows up) and is white noise:

.

In this section, I will show that the **generating functional** for this Ornstein-Uhlenbeck process is given by:

.

To show this, we apply the MSR formula to express the generating functional as a path integral:

.

This path integral can be solved exactly. The key observation is that the exponent is linear in , and hence one can integrate over this field. Using , this gives (up to a normalization factor ) a -functional:

.

The factor remains since it is the only term in the action independent of .

The -functional fixes in terms of :

.

From this we get

The normalization factor is seen to be by imposing that for we must have .

Plugging this in gives the generating functional, as claimed above:

.

One simple consequence is the **exponential decay of the connected correlation function**:

.

But of course, the full generating functional tells us much more – in some sense, it is the exact solution of the SDE!

*Note added 01/12/2012: Of course, the generating functional can be written down immediately once one knows the two-point correlation function and the fact that the Ornstein-Uhlenbeck process is Gaussian. However, the latter fact is not immediately obvious (and was not used in our derivation), in fact one can see our MSR calculation as one way to prove Gaussianity for the OU process.*

## Derivation of the Martin-Siggia-Rose formula

Now that we’ve seen what the MSR path integral formulation is useful for, let us see how it can be derived. The average over an observable can be written as a path integral with the SDE enforced through a -functional:

.

Now, we rewrite the -functional using the formula . Since the -functional is a product of a -function at all points in space, effectively we are introducing an auxiliary field :

.

Now, the only thing that depends on the noise is the factor . Since is Gaussian, the average of this factor can be simply expressed as

Altogether we obtain

which is just the MSR formula claimed above.

Amazingly, I did not yet find a clear derivation of this path integral representation on Wikipedia or anywhere else on the web… So I hope this will be useful for someone starting to work with the formalism!

If there is interest, I may write another blog post in the future with more examples and explanations e.g. on the physical role of the auxiliary field .