Correlated sample generator
Paste a covariance or correlation matrix, set the means, and draw multivariate-normal rows whose columns carry exactly the correlations you asked for. Seeded and reproducible, with a stats view that shows how close the sample landed.
About this tool
Generate reproducible multivariate-normal test data from the matrix you already know: a covariance matrix, a correlation matrix plus standard deviations, or a compact structure such as iid(4), cs(4, 0.3) or ar1(5, 0.7). The tool validates that the matrix is square and symmetric, checks whether it can be factorised, then turns independent seeded normal draws into correlated rows.
Use it for Monte Carlo fixtures, examples for statistics lessons, synthetic data with known dependence, or quick sanity checks before moving the same inputs into R, Python or a simulation pipeline. The default CSV output is easy to paste into a spreadsheet; JSON includes the achieved sample mean, covariance and correlation; stats output gives a compact target-versus-sample report.
Example: bivariate standard normals with correlation 0.8 and a fixed seed:
gizza tool correlated-sample-generator "1, 0.8; 0.8, 1" samples=5 seed=42 decimals=3
This returns two columns, X1 and X2, whose draws are reproducible for the same seed. Increase samples for a closer realised correlation, or set empirical=true when you need the sample covariance to match the target exactly.
Limits and edge cases
- Matrices can have up to 50 variables.
- Output is capped at 100000 rows and 200000 emitted numbers, so a 4-variable request tops out at 50000 rows.
choleskyis fastest but requires a positive-definite matrix. Useeigenfor positive-semidefinite cases such as perfect correlation.empirical=trueneeds more rows than variables because it standardises the generated sample before recolouring it.- Randomness is deterministic and local: no network calls, and the same seed and inputs produce the same rows across the CLI and browser page.
FAQ
Should I enter a covariance matrix or a correlation matrix?
Use the default covariance mode when the diagonal already contains variances and the off-diagonal entries are covariances. Choose correlation mode when the matrix has 1 on the diagonal and correlations between -1 and 1 off the diagonal; then enter sd values if each variable should have a standard deviation other than 1.
Why does my valid-looking matrix fail with Cholesky?
Cholesky needs the matrix to be strictly positive definite. A matrix with perfect correlation, a repeated variable or small rounding errors can be only semidefinite. Try method=eigen; it uses a symmetric square root and accepts positive-semidefinite matrices within the tolerance.
What does empirical mode change?
Normal random samples match the requested mean and covariance only in expectation, so a small sample will show sampling variation. empirical=true rescales the generated rows so their sample mean and sample covariance equal the requested targets exactly, which is useful for deterministic fixtures but less representative of random variation.
How do I make the same sample again later?
Keep the same matrix, means, method, seed and output settings. The generator uses a deterministic local PRNG rather than browser entropy, so the same inputs reproduce the same rows in the CLI, web page and tests.
Developer & Automation Access
Run it from the terminal
Same engine as this page, headless — via the gizza CLI:
gizza tool correlated-sample-generator "1, 0.8; 0.8, 1"New to the CLI? Get gizza →
Open it by URL
Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:
https://gizza.ai/tools/correlated-sample-generator/?covariance=1%2C%200.8%3B%200.8%2C%201&matrix_kind=covariance&sd=2%2C%203&mean=10%2C%20-4&samples=100&method=cholesky&seed=42&empirical=true&output=csv&decimals=4&labels=height%2C%20weight&header=true&tol=0.00000001Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.
