GenerateRandomSearch

Correlation Matrix Generator

Not every symmetric grid of numbers between minus one and one is a possible correlation matrix. If A and B correlate at 0.9 and B and C at 0.9, then A and C cannot possibly be at minus 0.9 — the constraint is that the matrix must be positive semi-definite, and hand-picked values routinely violate it. These are built from a factor model where the property holds by construction, then verified.

What this generator does

Gives each variable a random loading on a small number of shared factors, then computes the correlations that structure implies. Because the matrix comes from real loadings it is automatically a possible correlation matrix.

How to use this tool

  1. Choose how many variables and how many shared factors drive them.
  2. Read the matrix and find the strongest pair.
  3. Try more factors to see the structure get richer.
  4. Copy the matrix to use as a covariance structure.

Understanding the controls

How many variables
Between 3 and 8 named variables, which sets the size of the square matrix.
Shared factors
How many underlying influences the variables draw on. One factor makes everything correlate through a single driver; more gives a richer and more realistic structure.
Seed
Reproduces the same loadings and therefore the same matrix.

Worked examples

4 variables, 2 factors, seeded "demo"
Height, Weight, Age and Income come back with Height and Income correlating most strongly, at -0.57. Every entry sits between -1 and 1, the diagonal is all ones, and a Cholesky decomposition succeeds — which is what confirms the matrix is a genuinely possible correlation structure rather than an arbitrary grid of plausible-looking numbers.

Common use cases

  • Valid correlation structures for a simulation or a test
  • Showing why hand-picked correlations are often impossible
  • Teaching what positive semi-definite means in practice
  • Factor-model examples with visible shared drivers
  • Reproducing the same matrix from a seed

How this generator works

Correlations are the normalised dot products of the loading vectors, which is exactly how a factor model produces them. The check confirms the diagonal is all ones, the matrix is symmetric, every entry lies between minus one and one, and — the property that matters — that a Cholesky decomposition succeeds, which is what positive semi-definite means.

Randomness and fairness

The factor loadings are random; the resulting matrix is a deterministic consequence and its validity is proved. Seeded matrices reproduce and are therefore explicitly not cryptographically secure, and unseeded ones use the browser's cryptographically secure generator.

For how randomness is produced across the whole site, see how Generate Random works.

Limitations and good to know

  • Correlations come from a factor model, so the structure is always low-rank plus noise rather than arbitrary.
  • No underlying data is generated, only the matrix.
  • Variable names come from a fixed list.
  • Entries are rounded to two decimal places for display, and rounding can in principle disturb the property — which is why it is checked after rounding.
  • The matrix is not kept after the visit; seed it to reuse the same structure.

Privacy and your data

Loadings and correlations are computed in your browser. Neither is transmitted or stored; what is measured is that a matrix was made and how many rows were asked for.

Frequently asked questions

Why can't I just type in the correlation values I want?
Because most hand-picked grids of numbers between -1 and 1 are mathematically impossible as correlation matrices — if A and B correlate at 0.9 and B and C at 0.9, A and C simply cannot be at -0.9, no matter how intuitive that combination sounds. Building the matrix from a factor model guarantees the positive semi-definite property holds, which is the actual mathematical requirement, rather than hoping a hand-picked set of numbers happens to satisfy it.
What does increasing the number of shared factors actually change?
It changes how rich and varied the pattern of correlations can be. With one factor, every variable correlates with every other purely through that single common driver, which tends to produce mostly-positive correlations of similar sign. More factors let subsets of variables move together somewhat independently of other subsets, producing the mix of positive and negative correlations closer to what real multi-driver data looks like.