GenerateRandomSearch

Multivariate Normal Generator

Generating two correlated columns is a familiar trick. Generating five, all correlated with each other in a specified way, needs an actual method — and the standard one is to factor the covariance matrix and apply that factor to independent normals. The reason it works is exact algebra, not approximation, so this page checks the algebra rather than the sample: the factor multiplied by its own transpose must return the covariance you asked for.

What this generator does

Builds an equicorrelated covariance matrix with unit variances, factors it with Cholesky, and applies the lower-triangular factor to vectors of independent standard normals. The result has the requested covariance by construction. The factor is then verified by multiplying it with its own transpose and comparing against the target entry by entry.

How to use this tool

  1. Choose how many rows, how many dimensions, and how strongly the columns should correlate.
  2. Generate, and compare the measured covariance with the target you set.
  3. Increase the row count and watch the measured matrix settle towards the target.
  4. Copy as CSV to use the columns elsewhere.

Understanding the controls

How many rows
Between 20 and 400. More rows bring the measured covariance closer to the target, without changing the construction.
How many dimensions
Between 2 and 5 correlated columns. More dimensions with a high correlation push the covariance matrix towards singular, where it can no longer be factored.
Correlation
Between 0 and 95%, applied to every pair. Very high values with many dimensions push the matrix towards singular.
Seed
Any word reproduces the same sample and the same measured covariance.

Common use cases

  • Generating correlated features for a modelling or teaching exercise
  • Demonstrating why correlated predictors make regression coefficients unstable
  • Test data for a covariance or principal-components implementation
  • Showing Cholesky factorisation doing something useful
  • Setting the same dataset twice from a seed

How this generator works

Cholesky decomposes a symmetric positive-definite matrix into a lower-triangular factor times its transpose. Applying that factor to independent unit-variance normals produces vectors whose covariance is exactly the original matrix — the algebra is the guarantee. The check confirms the factor is genuinely lower triangular and that multiplying it out returns the target to within floating-point tolerance, which is a far stronger statement than any comparison against a finite sample could be.

Randomness and fairness

The draws are random; the covariance structure is exact by construction and verified algebraically. A seed reproduces the sample exactly and is therefore explicitly not cryptographically secure. Without a seed the browser's cryptographically secure generator is used.

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

Limitations and good to know

  • Equicorrelated only — every pair shares the same correlation rather than a freely specified matrix.
  • The measured covariance will not equal the target exactly, and should not; the factorisation is the exact part.
  • All variances are one, so the columns are on a common scale.
  • Correlation is capped below 1, where the matrix stops being positive definite and cannot be factored.
  • The data is not retained; the seed is what regenerates the same rows.

Privacy and your data

The sample and its covariance are computed entirely in your browser. Nothing about the data or your seed is transmitted or kept.