## 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.

## Estimating expected growth

Let’s take some fluctuating time series — say the value of some financial asset, like a stock price. **What is its average growth rate?** This seemingly trivial question came up in a recent discussion I had with a friend; obviously, it is relevant for quantitative finance and many other applications. Looking at it in more detail, it turns out that a precise answer is actually not that simple, and **depends on the time range** for which one would like to estimate the expected growth. So I’d like to share here some insights on this problem and its interesting connections to stochastic processes. Suprisingly, this was only studied in the literature quite recently!

## The setup

Let’s consider the price of an asset at discrete times . The corresponding **growth rates** are defined by

(1)

I.e. if , the growth rate is . Let’s also assume that our growth process is **stationary**, i.e. that the distribution of the growth rates does not change in time. Say for concreteness that the growth rates are i.i.d. (independent identically distributed) random variables.

## The arithmetic average

The most immediate idea for computing the average growth rate is just to take the **arithmetic average**, i.e.

(2)

What does this give us? Obviously, by the assumption of stationarity made above, with increasing sample size the expectation value for the growth rate at the next time step (or any other future time step) is approximated better and better by :

This seems to be what we’d expect for an average growth rate, so what’s missing? Let’s go back to our sample of asset prices and take the total growth

By the relationship between the arithmetic and the geometric mean, we know that

(3)

The left-hand side is the total growth after time periods and the right-hand side is its estimate from the arithmetic mean in eq. (2). Equality only holds in eq. (3) when all the are equal. When the fluctuate the total growth rate will always be strictly less than the estimate from the arithmetic mean, even as . **So, by taking the arithmetic mean to obtain the total growth in the price of our asset at the end of the observation period, we systematically overestimate it.** The cause for this is the **compounding** performed to obtain the total growth over more than one time step. This makes our observable a **nonlinear function of the growth rate in a single time step**. Thus, fluctuations in the growth rate don’t average out, and yield a net shift in its expectation value.

The first explicit observation of this effect I’ve found is in a 1974 paper by M. E. Blume, *Unbiased Estimators of Long-Run Expected Rates of Return*. Quantitative estimates from that paper and from a later study by Jacquier, Kane and Marcus show that in typical situations this overestimation may easily be **as large as 25%-100%**.

## The geometric average

So we see that the arithmetic mean does not provide an unbiased estimate of the compounded growth over a longer time period. Another natural way to obtain the average growth, which intuitively seems more adapted to capture that effect, is to take the **geometric average of the growth rates**:

(4)

Now, by construction, the total growth at the end of our observation period, i.e. after time periods, is correctly captured:

But this only solves the problem which we observed after eq. (3) for this specific case, when estimating growth for a **time period whose length is exactly the same as the observation time span** from which we obtain the average. For shorter time periods (in particular, when estimating the growth rate for a single time step ), the geometric mean will now **underestimate** the growth rate. On the other hand, for time periods even longer than the observation period, it will still overestimate it like the arithmetic mean (see again the paper by Blume for a more detailed discussion).

## Unbiased estimators

Considering the results above, the issue becomes clearer:** A reasonable (i.e. unbiased) estimate for the compounded growth over a time period requires a formula that takes into account both the number of observed time steps , and the number of time steps over which we’d like to estimate the compounded growth . ** For we can use the arithmetic mean, for we can use the geometric mean, and for general we need another estimator altogether. For the general case, Blume proposes the following (approximately) **unbiased estimator** :

(5)

**Eq. (5) is a reasonable approximation for the compounded growth**, not having any further information on the form of the distribution, correlations, etc.

For , i.e. estimating growth in a single time step, this gives just the arithmetic mean which is fine as we saw above. For , this gives the geometric mean which is also correct. For other values of , eq. (5) is a linear combination of the arithmetic and the geometric mean.

To see how the coefficients in eq. (5) arise, let us start with an ansatz of the form

(6)

Let us further split up the growth rates as , where is the “true” average growth rate and are fluctuations. Inserting this as well as the definitions of into eq. (6) we get

Now let us assume that the fluctuations are small, and satisfy . Expanding to second order in (the first order vanishes), and taking the expectation value, we obtain

To obtain an estimator that is unbiased (to second order in ), we now choose and such that the term of order is just the true growth rate , and the term of order vanishes. This gives the system

The solution of this linear system for and yields exactly the coefficients in eq. (5).

Of course, here we make the assumption of small fluctuations and also a specific ansatz for the estimator. If one has more information on the distribution of the growth rates this may not be the most adequate one, but with what we know there’s not much more we can do!

## Outlook

As you can see from the above discussion, estimating the expected (compounded) growth over a series of time steps is more complex than it appears at first sight. I’ve shown some basic results, but didn’t touch on many other important aspects:

- In addition to the growth rate , it is also interesting to consider the discount factor . Blume’s approach is extended to this observable in this paper by Ian Cooper.
- If one assumes the growth factors in eq. (1) to be
**log-normally distributed, the problem can be treated analytically**. Jacquier, Kane and Marcus discuss this case in detail in this paper, and also provide an exact result for the unbiased estimator. - The assumption of independent, identically distributed growth rates is not very realistic. On the one hand, we expect the distribution from which the annual returns are drawn to vary in time (i.e. due to underlying macroeconomic conditions). This is discussed briefly in Cooper’s paper. On the other hand, we also expect some amount of correlation between subsequent time steps, even if the underlying distribution does not change. It would be interesting to see how this modifies the results above.

Let me know if you find these interesting — I’ll be glad to expand on that in a future post!

## Simulating Directed Polymers and the Tracy-Widom Distribution

A few posts ago I briefly talked about the problem of a directed polymer in a random medium. In that post, I discussed the scaling behaviour of the polymer fluctuations due to the disordered environment, i.e. its roughness exponent, in dimensions.

As with many other statistical physics problems, for gaining an intuitive understanding it is also useful to perform some numerical simulations. In this post I will show how the directed polymer partition sum can be simulated using Wolfram Mathematica. I will also compare the results to the known exact result for the distribution of the free energy, the Tracy-Widom distribution.

# The transfer-matrix algorithm

The partition sum of the directed polymer is defined as the sum over all directed paths of the Boltzmann weights of each path. The energy of the path is the sum over the random energies of the sites which are touched by . is the inverse temperature.

In any space dimension, this partition sum can be evaluated rapidly by using a **transfer-matrix algorithm**. Let us order the lattice along the longitudinal direction of the directed polymer . Then, the partition sum at site is obtained from the partition sums at this site’s neighbours in the preceding slice :

.

For the free energy , we obtain

.

Let us focus on the case of very low temperatures, . Then the logarithm is dominated by the neighbour with the minimal (i.e. most negative) free energy . Hence we obtain

.

This also makes sense intuitively: At zero temperature, the partition sum of the directed polymer is dominated by the minimal-energy configuration. The “cost” of getting to site is the cheapest “cost” of getting to one of its neighbours, augmented by the (fixed) cost of going to site .

# The `Mathematica`

simulation code

The following short `Mathematica`

routine returns the free energy at the final time for a directed polymer

```
fe =
Compile[{{wd, _Integer}, {len, _Integer}},
Module[{pot1, pot2, fval},
pot1 = RandomVariate[NormalDistribution[], {len, wd}];
pot2 = RandomVariate[NormalDistribution[], {len, wd}];
fval = ConstantArray[0., wd];
Do[fval = (fval - (fval - RotateLeft[fval]) UnitStep[
fval - RotateLeft[fval]]) + pot1[[k]];
fval = (fval - (fval - RotateRight[fval]) UnitStep[
fval - RotateRight[fval]]) + pot2[[k]];, {k, 1, len}];
Return[fval]]];
```

`k`

is the longitudinal coordinate of the polymer, and runs from `1...len`

. The vector `fval`

has `wd`

components and contains the free energy values at the current value of `k`

, for all transversal coordinates `x=1...wd`

.

For each `k`

I perform two steps forward, one where site `i`

neighbours on `i+1`

and `i`

, and one where site `i`

neighbours on `i`

and `i-1`

. This ensures that in the end one obtains a standard square lattice of size `2lenwd`

, where the directed polymer can choose between two symmetric alternatives at each time step. `pot1`

and `pot2`

are `lenwd`

matrices containing the random energies for each site, for the even and odd values of `k`

, respectively.

Since `Mathematica`

‘s built-in `Min`

function does not operate componentwise on vectors, I emulate it by using the componentwise `UnitStep`

function:

`a-(a-b)UnitStep[a-b] = Min[a,b]`

.

At , I use a free initial condition: , i.e. the polymer end at can be anywhere. Modifying the line

`fval = ConstantArray[0., wd];`

,

one can change this e.g. to a fixed initial condition where the polymer end at is fixed.

The returned value is the vector where `x=1...wd`

and `t=2len`

is the final time.

For example, to generate samples of the free energy for a directed polymer on a lattice, with the final end fixed, and the initial end free, you would call

Table[fe[256,128][[1]], {10000}]

Note that the `[[1]]`

picks out the free energy for a fixed final site. This simulation takes about a minute on my laptop.

# The Tracy-Widom distribution of the directed polymer free energy

Theory predicts the following form for the free energy of the directed polymer model in dimensions:

,

where indicates terms subdominant in . is a constant and is the nonuniversal, deterministic part of the free energy. The *fluctuations* of the free energy due to randomness of the disorder, described by the second term, *are universal*: The random variable is distributed according to a Tracy-Widom distribution, and only its amplitude depends on discretisation details.

The precise distribution depends on the symmetries imposed by the initial condition.

- For a polymer free at , , where is the Tracy-Widom distribution for the Gaussian Unitary Ensemble (GUE).
- For a polymer fixed at , , where is the Tracy-Widom distribution for the Gaussian Orthogonal Ensemble (GOE).

The functions and are solutions of Painlevé differential equations. Tables of their numerical values can be found with very high precision e.g. on the web page of M. Prähofer.

In the figure on the right you can see how this theoretical prediction compares to numerical simulations using the code above. To get rid of the nonuniversal constants and , I consider the “normalized” free energy

.

We see that its distribution observed in directed polymer simulations has a skewed shape, which agrees very well with the Tracy-Widom prediction (clearly much better than with the symmetric Gaussian distribution). In the tails, one can even “almost” distinguish the two universality classes corresponding to different initial conditions. For the difference to be really significant, one would need to run some longer simulations though.

# Further optimizations

Naturally one would like to make the simulation even faster, in order to have better statistics and reach higher system sizes. One may think that implementing the code above in a low-level programming language (e.g. `C++`

) would yield a large performance gain. However, it turns out that a naive `C++`

implementation (where the operations on the free-energy vector are implemented by a simple loop over the transversal coordinate ) is actually about three times *slower* than the `Mathematica`

code above. This is since such array-wise operations can be optimized by using modern processor SIMD extensions, which are utilized in `Mathematica`

‘s routines.

Of course, one can also take advantage of this in `C++`

. One can either hand-optimize the loop over transversal coordinates using the processor-dependent SIMD routines, or use an array math library. For example, I implemented the transfer-matrix algorithm above in `C++`

using the vector routines from Intel’s Math Kernel Library, and was able to achieve a speed-up by a factor of five compared to the `Mathematica`

code. Still, considering the ease of programming and debugging, I find that the simple `Mathematica`

implementation fares amazingly well!

If you’re interested in more details, references, higher-dimensional versions, the `C++`

code, or anything related, go ahead and drop me a comment below — I’ll extend this post if there is interest 😉

## Fokker-Planck equation for a jump diffusion process

One of the simplest stochastic processes is a Brownian motion with drift, or a **diffusion process**:

(1)

Here, is Gaussian white noise with mean zero and variance . Its integral is a Brownian motion.

Continuous Itô stochastic processes such as eq. (1) are insufficient for applications where the random variable may jump suddenly (such as in avalanches). A natural extension of (1) for modelling this is a so-called **jump-diffusion process**. Let us suppose that our jump sizes are positive, independent and identically distributed with density . Then, the jump diffusion process is

(2)

where are i.i.d. jump sizes as above, and is the number of jumps encountered up to time . For simplicitly, let us assume that jumps occur independently with rate , i.e. that the probability to have a jump in a time interval is . Then, is a Poisson process with rate .

It is well-known that the diffusion process in (1) is equivalently described by a partial differential equation for the distribution of , the **Fokker-Planck equation** (FPE)

. (3)

This representation is useful e.g. for first-passage problems: they correspond to various boundaries introduced in the PDE (3). **So how does one generalise the Fokker-Planck (3) to the case of the jump-diffusion process in (2)? ** I will explain in the following that the answer is

, (4)

and then discuss a specific example.

## 1. Deriving the jump-diffusion FPE

Let us consider a time step from to . The probability for a jump to occur during this interval is , so

, (5)

where denotes averaging over all realizations of the Brownian motion , and denotes averaging over the distribution of the jump size . Since the jump term is already multiplied by the jump probability , the drift and noise contributions there are of higher order in and were dropped.

The averaging over the jump size in (5) yields a convolution with the jump size distribution :

.

The average over the noise in (5) is the same as for standard diffusion. During the interval , the increment of the noise term in (2) is

,

where the last equality is a definition for .

Since is a Brownian motion, is normally distributed:

.

Thus, the average over in (5) is

.

In the last line we used the fact that the normal distribution has mean zero and variance 1, and dropped all terms of higher order than . Inserting all this into (5), we obtain the jump-diffusion FPE (4).

## 2. Example: Exponential jumps

Now let us consider a simple example, where the jump sizes are distributed exponentially:

.

We will compute the distribution of , starting from .

For this, we solve the jump-diffusion FPE (4) with the initial condition . Let us take a Fourier transform of (4) from to :

.

The different spatial modes decouple, and instead of a partial differential equation we obtain an ordinary differential equation for each value of the Fourier variable .

For the above exponential form of the jump size distribution ,

.

Furthermore, the initial condition gives . Hence, the solution $\tilde{P}$ reads

.

While it does not seem feasible to invert this Fourier transform to obtain a closed expression for (but if anyone has an idea, let me know!), is already enough to determine the moments of . Taking derivatives, we obtain for example

.

Similarly, solving the FPE (4) with an absorbing boundary allows computing first-passage times (or at least their moments) for our jump-diffusion process.

Have fun, and do let me know if you have any comments!

## Tricks for inverting a Laplace Transform, part V: Pole Decomposition

*This is a continuation of my articles on methods for inverting Laplace transforms. You can find the previous parts here: part I (guesses based on series expansions), part II (products and convolutions), part III, part IV (substitutions).*

## 1. Result

In this post I will explain how to find the inverse of the following Laplace transform:

. (1)

The solution is given in terms of the Jacobi theta function (which can be re-expressed in terms of Jacobi elliptic functions, though I won’t discuss that here in detail):

. (2)

By taking derivatives or integrals with respect to , which are equivalent to multiplication or division of by , one can obtain many other Laplace transform identities, including for example

.

If anyone manages to find a systematic list of those, I’d be very grateful. But for now let’s just see how one obtains (2).

## 2. Derivation

First, we use the classic decomposition of trigonometric functions in infinite products due to Euler:

.

From the second identity, we can obtain a partial fraction decomposition of (following this post on StackExchange):

.

Applying this to the right-hand side of (1), we obtain a sum over simple poles:

The Laplace inverse of a simple pole is just an exponential, . By linearity of the Laplace transform, we can invert each summand individually, and obtain an infinite sum representation for :

This sum can now be evaluated with `Mathematica`

‘s `Sum`

command, or by hand using the representation of theta functions in terms of the nome, for argument and . This finally gives the solution as claimed above:

. (2)

Have fun!

## Mean-field solution of the Random Field Ising Model

A happy new year to all the blog readers out there!

Today I will discuss a classical model of a disordered system that is extremely simple to write down: The Ising model with quenched (i.e. time-invariant) local random fields.

This model, also dubbed the *Random-Field Ising Model (RFIM)*, is highly non-trivial. Above two dimensions, depending on the strength of the local random fields, it exhibits a phase transition between an ordered (**ferromagnetic**) and a disordered (**paramagnetic**) phase. When applying an additional homogeneous time-varying magnetic field, the local random fields prevent some regions from flipping. This leads to interesting phenomena like avalanches and hysteresis. The avalanche sizes, and the shape of the hysteresis loop, vary depending on the location in the phase diagram. Experimentally, this phenomenology – including the disorder-induced phase transition, avalanches, and hysteresis – describes very well e.g. helium condensation in disordered silica aerogels.

In this blog post, I will discuss the solution of the RFIM in the fully connected limit. This means that the ferromagnetic interaction between any two spins, no matter how far apart, has the same strength. This limit, also called the *mean-field* limit, is supposed to describe the model accurately for a sufficiently high spatial dimension. Just how high is “sufficient” is still a matter of debate – it may be above four dimensions, above six dimensions, or only when the dimension tends to infinity. Nevertheless, the mean-field limit already captures some of the interesting RFIM phenomenology, including the ordered-disordered phase transition. This is what I will discuss in this blog post. I will follow closely the original paper by T. Schneider and E. Pytte from 1977, but I’ve tried to extend it in many places, in order to make the calculations easier to follow.

## 1. The mean-field RFIM Hamiltonian and its free energy

The energy of fully connected Ising spins , , subject to local random fields , is:

The prefactor in the first term (the ferromagnetic interaction energy) is chosen so that the scaling of this term with is the same as the scaling of the second term (containing the random fields).

The corresponding partition sum is the thermal average over all spin configurations:

As usual, is the inverse temperature of the system.

In order to see the phase transition, we need to consider the free energy , averaged over all random fields :

Through a somewhat lengthy calculation (which I explain in detail in the last section 3. of this post), one obtains the following expression for the disorder-averaged free energy:

where the typical magnetization is fixed through the **implicit (self-consistent) equation**

is the probability distribution of the random fields, assumed to be Gaussian with mean zero and variance :

Although the expression above for the free energy is written in terms of , strictly speaking I will show it only for the case where has this Gaussian form. Whether the formula for the free energy also holds for other is a good question which I’d like to understand better – if any expert happens to be reading this and can clarify, it would be great!

Now, let’s look at what information on the phase diagram of the model we can deduce from these expressions.

## 2. Phase diagram of the mean-field RFIM

The self-consistent equation for the magnetization given above has a trivial solution for all values of the parameters . Similar to what happens in the mean-field solution for the standard Ising model, if is sufficiently large, the slope is larger than one and there is another non-trivial solution (see figure on the right). This indicates the existence of ferromagnetic order. Thus, the

**phase boundary between the paramagnetic and the ferromagnetic phase**is given precisely by the condition

One of the three parameters can be eliminated by rescaling . For example, we can eliminate and express the phase transition line in terms of the dimensionless variables , , :

Another way is to scale away , setting , .

Then one has the following expression for the phase boundary

With this expression, we see more clearly that there is a well-defined zero-temperature limit. When , we get a transition at

This is quite interesting, since it indicates a phase transition driven purely by the fluctuations of the quenched disorder, without any thermal noise!

More generally, we can easily plot the phase diagram in terms of using `Mathematica`

; see the figure on the left.

Of course, the expression for the free energy given above can also be used to deduce more elaborate observables, like the susceptibility, etc. For this, I refer to the original paper by T. Schneider and E. Pytte. For example, one can find that near the phase transition the magnetization with a power-law,

This is the typical **mean-field power law**, which is also found when studying the phase transition in the pure Ising model on the mean-field level.

Now that we’re convinced that these formulas for the free energy and the magnetization (boxed in orange above) are useful for understanding the physics of the mean-field RFIM, I will explain in detail how they were derived.

## 3. Calculating the free energy using the replica trick

Since averages over the logarithm of a random variable are not easy to compute, we use the *replica trick* to re-express the free energy in terms of moments of :

is the partition sum of copies, or *replicas*, of the system, feeling the same random fields . Indexing these copies by greek indices , we get

Since the are independent and Gaussian (with mean 0 and variance ), . Then

We have performed the disorder averaging, so what remains is the partition sum of copies/replicas of a *non-disordered* fully-connected Ising model. They are interacting via the second term in the exponential, which came from the disorder averaging. We will now compute the partition sum of this *replicated Hamiltonian*. The plan for this is the following:

- Decouple the individual sites using a Hubbard-Stratonovich transformation.
- Apply the saddle-point method to compute the integral. Due to the decoupling, the saddle-point is controlled by the number of sites . Thus, this procedure is exact in the thermodynamic limit .

To apply the Hubbard-Stratonovich transformation, we first rewrite the ferromagnetic interaction as

and then use

In order to have an exponential scaling homogeneously with the system size, we set :

The exponential is now a linear sum over all sites , without any interaction between them. Thus, the partition sum is the -th power of the partition sum of a single site:

where is the partition sum for all replicas on a single site:

In the thermodynamic limit , the integral in our expression for is dominated by its saddle point (due to the fact that the exponential is linear in ). At the saddle point, by symmetry we can assume all the to be equal. Setting for all , the exponent of the integrand in the above expression for becomes

.

Hence, the saddle-point value is fixed by the implicit equation

where

We see that effectively, the saddle-point location corresponds to a fixed average magnetization , for the replicated spins on a single lattice site, subject to the “Hamiltonian” . Rewriting everything in terms of the magnetization , we get

is fixed by the implicit (self-consistent) equation

Now, to further simplify the result, we can compute the sums over all spin configurations by performing another Hubbard-Stratonovich transformation:

Then, the single-site partition sum can be computed as following:

Similarly, the self-consistent equation for the mean magnetization simplifies to:

In order to obtain the disorder-averaged free energy, as discussed above we need to take the derivative with respect to at :

The magnetization is fixed by the self-consistent equation at :

By the substitution , these formulae reduce to those shown in section 1, and then used to analyze the phase diagram in section 2.

As always, I’m happy about any questions or comments!!