From CorrGAN to CorrFlow
Generating realistic correlation matrices, from the first GAN experiments to geometric flow matching.
I have always been interested in covariance and correlation matrices as mathematical objects. They are also central to my professional life in quantitative investing and trading, which gives me plenty of reasons to keep thinking about them.
My interest in their geometry goes back to around 2015–2017, during my PhD, when I was working on information geometry with Frank Nielsen. I had raised questions about applying covariance-matrix geometry to correlation matrices, but did not pursue them very far. There is a short collection of research notes from 2017 on the blog.
The difficulty is that correlation matrices form a constrained subset of covariance matrices: their diagonal entries must all equal one. Under the usual affine-invariant covariance geometry, a geodesic joining two correlation matrices can leave that subset. In mathematical terms, it is not a totally geodesic submanifold. I later illustrated the problem in a 2019 post on defining a Riemannian mean of correlation matrices: even the midpoint along that covariance-space geodesic need not be a correlation matrix.
Alongside these geometric questions, I became interested in learning to generate financial correlation matrices. The first CorrGAN experiments appeared on this blog in 2019. Could we learn to sample matrices that resemble those estimated from financial returns, and use them to study correlation estimators, portfolio construction and risk?
We already had algorithms for sampling valid correlation matrices. The onion method, for example, gives us a way to explore the space of possible matrices. Financial correlations have additional structure: a strong market mode, groups of assets that move together, and hierarchical relationships. The aim was to learn that structure from data.
Those experiments led to CorrGAN, then conditional CorrGAN, or cCorrGAN. They also exposed several difficulties: generating valid matrices, handling the arbitrary order of assets, and checking whether the generated scenarios cover the variety seen in real data.
Over the following years, researchers developed tools specifically for correlation matrices. Work by Yann Thanwerdas and Xavier Pennec, for example, introduced intrinsic geometries with tractable operations. Separately, Ilya Archakov and Peter Reinhard Hansen developed an unconstrained parametrization of full-rank correlation matrices, generalizing the Fisher transform. This is the parametrization used in CorrFlow.
Following these developments made me want to return to the problem. There were now mathematical tools I could put to use in a concrete project, and the earlier CorrGAN experiments gave me specific difficulties against which to test them.
I also wanted a project I could release publicly, sufficiently separate from my professional work. A follow-up to CorrGAN was a natural choice: the earlier experiments gave me a problem to revisit, and specific difficulties against which to test a more principled construction. Could the newer mathematical tools improve how we generate correlation matrices?
That led to CorrFlow, which combines the generalized Fisher transform, a permutation-equivariant graph network and flow matching. It makes validity and the response to asset relabeling part of the construction. The paper was accepted for a poster at NeurReps 2026, and the code is public.
This post explains how we got here and what has changed. A series of articles will follow, working through the geometry, methodology and underlying mathematics with small numerical experiments.
From three correlations to CorrGAN
In the first CorrGAN experiment, I started with three variables. A symmetric 3-by-3 matrix with ones on its diagonal has just three free coefficients, so we can plot it as a point in three dimensions. Valid matrices occupy a curved region called the elliptope.
This made it possible to see a failure directly: some GAN-generated points fell outside the elliptope. Their coefficients looked individually reasonable, but together they described an impossible correlation structure. For example, correlations of 0.9 between A and B, 0.9 between A and C, and −0.9 between B and C produce a negative eigenvalue. Some linear combination of these variables would have a negative variance.
The second experiment moved from uniform sampling to empirical financial correlations. It already raised two questions that would stay with the project: does the generator cover the empirical distribution, and how should it handle different orderings of the same variables?
Scaling up made the representation more important. A 100-by-100 MLP-based GAN failed to reproduce the financial stylized facts. The DCGAN experiment was more successful: hierarchical clustering arranged the assets into visible blocks, and a convolutional GAN learned several spectral, hierarchical and network properties.
That was useful progress. It also left two structural problems. The generated arrays needed symmetry and diagonal corrections, followed by a nearest-correlation projection. And the image representation relied on a chosen asset ordering. The clustering step helped expose structure, but the network itself did not enforce the symmetry associated with relabeling assets.
What cCorrGAN added
The 2021 cCorrGAN post described work by Victor Goubet, Chloé Daems, Thomas Graff and Quentin Bourgue extending CorrGAN to market-regime conditioning: stressed, normal and rally markets. We presented the method in the cCorrGAN paper, coauthored with Victor Goubet and Frank Nielsen and published at Geometric Science of Information in 2021.
This changed the question from sampling a plausible financial correlation matrix to sampling one associated with a requested market state. The paper used these conditional samples in Monte Carlo simulations to compare risk-based portfolio allocation methods.
The 2020 assessment of CorrGAN had also exposed a broader issue: the model could reproduce many observed properties while missing parts of the empirical distribution. For scenario generation, that matters. A collection of convincing samples can still omit situations we need to study.
How CorrFlow changes the construction
CorrFlow keeps the goal of conditional generation and revisits the representation and network.
Generate in coordinates with a valid inverse
The generalized Fisher transform gives each positive-definite correlation matrix an unconstrained real coordinate vector. It uses the off-diagonal entries of the matrix logarithm; the inverse recovers the missing diagonal before exponentiating.
This is the matrix counterpart of a familiar idea: transform a constrained quantity into coordinates where ordinary real-valued calculations are possible. In two dimensions, it reduces to the usual Fisher transform of a single correlation coefficient.
We learn the distribution in those coordinates, then apply the inverse transform. Every finite coordinate vector corresponds to a positive-definite correlation matrix. Symmetry, unit diagonal and positive definiteness follow from the representation. The nearest-correlation repair step disappears. The inverse is computed numerically, so reconstruction accuracy depends on its solver tolerance.
Make asset relabeling part of the architecture
Suppose we move an asset from the first position to the fifth. Its row and column move together. We have changed the layout of the matrix while describing the same financial system.
This was already the subject of my 2019 post on permutation invariance. For a generator, the relevant property is equivariance: reorder the input noise and the output should be reordered in the corresponding way.
CorrFlow represents variables as graph nodes and transformed correlations as edges. Each node summarizes its connected edges using operations such as averages, which give the same result regardless of their order. Each edge is then updated by the same learned rule, treating its two endpoints symmetrically. Reordering the assets therefore moves the calculations to new positions without changing what they compute. This makes the network equivariant by construction. The coordinate transform respects the same symmetry, so the complete generator can work directly with any asset ordering, without a clustering-based ordering step.
Learn a transport from noise to data
During training, we pair Gaussian noise with a transformed empirical matrix, interpolate between them, and train a network to predict the connecting velocity. At generation time, we start with fresh noise and integrate the learned velocity field, then transform the endpoint back to a correlation matrix. Market conditions enter the velocity network.
This replaces adversarial training with a velocity-regression objective. The geometry and symmetry come from the coordinates and architecture; flow matching supplies the mechanism for learning the distribution. Diffusion can also be used with these ingredients.
| Earlier construction | CorrFlow |
|---|---|
| Generate an array, then repair it into a correlation matrix | Generate coordinates whose inverse is a positive-definite correlation matrix |
| Arrange assets into an image order before learning | Use a graph network that respects asset relabeling |
| Train a generator against a discriminator | Regress a velocity field and integrate it to generate samples |
| cCorrGAN conditions on a market regime | Retain conditional generation, with regime and a continuous performance score in the financial experiment |
What improves in the experiments
On the paper’s Taiwan benchmark, with 80 assets, 20 training epochs and five seeds, CorrFlow generated valid matrices without repair in every evaluated draw.
For comparison, historical replay simply resamples stored training-period matrices from the requested market regime. It preserves observed examples exactly, but cannot generate new ones. CorrFlow’s mean feature sliced-Wasserstein distance was 0.712 ± 0.141, compared with 0.886 ± 0.010 for replay. This distance compares distributions of structural summaries, such as eigenvalue and correlation statistics; lower values mean a closer match.
The comparison is with matrices from the later test period. Training uses 2014–2020 and testing uses 2023–July 2026, and our diagnostics show a substantial change in their correlation structure. Replaying the past therefore gives us genuine historical scenarios, but their distribution differs from the test-period target. CorrFlow obtains a closer match on this aggregate distance; whether it captures the variety of scenarios is a separate question.
We also trained cCorrGAN and an image-based diffusion model on the same Taiwan data, giving each model 20 passes through the training set. On the same distance measure, CorrFlow’s samples were closer to the test data than those produced by either model.
Which challenges remain
Covering the range of scenarios. An 80-asset matrix has 3,160 distinct pairwise correlations. Comparing distributions of these matrices is harder than comparing a single correlation coefficient. We use 21 summaries, including correlation and eigenvalue statistics, to make the comparison manageable. But different matrices can have similar summaries, and a good overall distance can hide parts of the distribution that the generator rarely visits.
We therefore also check how well real test cases are covered by neighborhoods around generated samples, and train a classifier to distinguish generated from real matrices using those summaries. Historical replay covers the test cases better on the neighborhood check, while the classifier separates CorrFlow samples from real ones almost perfectly. These measurements show that the lower distance reported above comes with gaps: reproducing a broader range of scenarios remains an open problem.
Changing matrix size. The same network parameters can be evaluated on graphs of different sizes. Our tests show that this alone does not give reliable transfer to a new size. There is also a stronger requirement: generating 40 assets directly should agree in distribution with extracting 40 assets from a larger generated matrix. This is called projective consistency, and permutation equivariance does not ensure it.
Knowing what the variables represent. Anonymous asset subsets let us study dependence structure without fixing security identities. For a named portfolio, sector, country and other asset attributes matter. They need to move with their nodes when we reorder the matrix.
We train CorrFlow on correlation matrices calculated from 252 daily returns. Even if the underlying relationships between assets stayed unchanged, another sample of 252 returns would give slightly different correlations just by chance. Differences between our matrices therefore reflect both changes in the market and the uncertainty introduced by estimating correlations from limited data. CorrFlow currently learns these two sources of variation together. Separating them would help us study changes in the underlying correlations and estimation error as distinct effects.
The articles to follow
The series will develop these ideas through calculations, code and visual examples. The early experiments use small matrices so that we can inspect what happens.
-
Why correlation matrices are difficult to generate. Construct an impossible three-variable example, inspect its negative eigenvalue, and visualize the elliptope.
-
The generalized Fisher transform, step by step. Start with one correlation, derive the matrix representation, and measure numerical reconstruction error.
-
Flow matching from noise to correlations. Derive the velocity-regression objective and integrate a toy field with a known solution.
-
Permutation equivariance and variable identities. Test relabeling directly, then examine why the meaning of each node matters.
-
Evaluating generated correlation matrices. Compare validity, structural fidelity and coverage using deliberately different failure cases.
-
From raw returns to a reproducible benchmark. Build matrices and examine asset selection, estimation and overlapping windows.
-
Correlation generation beyond finance. Examine the brain-connectivity and weather pilot studies and their task-specific outcomes.
-
CorrFlow and DiffeoCFM in a matched comparison. Reconstruct the reported comparison and examine how conditioning, training budgets and checkpoint selection affect the results.
Code and examples
The public repositories are CorrFlow for the geometric generators, CorrBench for data construction and evaluation, and CorrGAN for the GAN implementations. The series will use small executable examples alongside the paper’s recorded experiments.
We will begin where the original experiments began: three correlations that we can plot, change and check.