Skip to content
All library documents

Generating Correlated Geometric Brownian Motion Paths with Cholesky Factors

Article Quant Q&A · Author: Willart

Summary

The document asks how to apply a Cholesky factor to simulated normal draws when generating two correlated geometric Brownian motion processes. It compares a Matlab pattern that stores time steps in rows and processes in columns with a Python pattern that stores processes in rows and time steps in columns. The question is whether the differing array orientations make one implementation incorrect.

The key is that a Cholesky factor’s multiplication side must match the orientation of the random-draw matrix: right multiplication is appropriate when each draw is a row, while left multiplication fits draws arranged as columns. Either arrangement can produce correlated shocks if dimensions and conventions are consistent. The post itself poses the discrepancy but provides no answer, numerical check, or derivation, so it does not establish which sample code is correct in its full simulation context. Users must also distinguish correlation of shocks from the subsequent GBM drift, volatility, and time-step scaling.

Key ideas

  • A Cholesky factor transforms independent standard normal draws into correlated shocks.
  • The multiplication side depends on whether processes occupy rows or columns.
  • Array orientation alone does not determine correctness; dimensions and covariance conventions must agree.
  • The document raises the implementation question but gives no resolution or validation.

Tags

Full text
# Simulating correlated Geometric Brownian Motion in Python


# Simulating correlated Geometric Brownian Motion in Python












I want to simulate two correlated Geometric Brownian Motion processes in Python. I found an implementation from Matlab (https://www.goddardconsulting.ca/matlab-monte-carlo-assetpaths-corr.html) and another one in Python (https://mikejuniperhill.blogspot.com/2019/04/python-path-generator-for-correlated.html) which both should do exactly what I'm looking for, however I noticed something different between both and I'm not sure which one is correct.

Here are the specific parts I'm talking about:

Matlab implementation:

```
R = chol(corr);
x = randn(steps,size(corr,2));
ep = x*R;
```

Python implementation:

```
choleskyMatrix = np.linalg.cholesky(correlation)
e = np.random.normal(size = (nProcesses, nSteps))            
paths = np.dot(choleskyMatrix, e)
```

In both implementations the Cholesky Matrix is calculated, however then the two dimensions of the random sequence `x` and `e` respectively are flipped. As a result, the matrix multiplication/dot product yields to a different result caused by the different dimensions of the array. Which one of these implementations is correct?

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.