GenerateRandomSearch

Correlated Dataset Generator

The site's synthetic test data generator builds tables of people: names, emails, addresses. Its numbers are uniform noise, because plausible people is the point. That is exactly the wrong data for testing a scatter plot, a cleaning pipeline or an anomaly detector, all of which need numbers with a known shape. This produces two columns with the correlation you ask for, and lets you add blanks, duplicate rows and outliers on purpose — then tells you what it actually produced rather than what you requested.

What this generator does

Builds a bivariate normal sample at the correlation you specify, then optionally damages it in the specific ways real data is damaged. The important detail is that it measures the result: a finite sample never lands exactly on its target correlation, so the tool reports both the number you asked for and the number the data actually has. Everything shown is recomputed from the rows rather than carried over from the request.

How to use this tool

  1. Choose how many rows and how strongly the two columns should correlate.
  2. Add blanks, duplicates or outliers if you are testing how something copes with them.
  3. Generate, then copy the result as CSV or JSON.
  4. Use a seed if the dataset needs to be identical every time.

Understanding the controls

How many rows
Between 10 and 500. Sample size matters here more than anywhere else on the page: at 20 rows the measured correlation can be a long way from the target, which is itself a useful thing to demonstrate.
Correlation
From -100% to 100%. Zero gives two genuinely independent columns, which is the right control case when you are testing whether something claims to see a relationship that is not there.
Blank values
Up to half the cells, spread across both columns. Note that the reported correlation is then measured only over rows where both values survive — which is what a real analysis does, and is not the same number as before blanking.
Duplicate rows
Whole rows copied from earlier ones, keeping their own id. That is the shape a careless join produces, and it is harder to spot than a blank.
Outlier rows
Values pushed far outside the plausible range, on one column only — the shape of a sensor fault or a unit mix-up rather than a row that is uniformly strange.
Seed
Reproduces the dataset exactly, which is what you need if the fixture is committed and a test asserts against specific values.

Common use cases

  • Checking that a scatter plot and its trend line behave at a known correlation
  • Testing a data cleaning pipeline against blanks, duplicates and outliers you planted yourself
  • Giving students a dataset whose correlation is known so their answer can be marked
  • Seeing whether an anomaly detector finds the outliers you put there and nothing else
  • Testing that a statistics function drops incomplete rows the way you expect

How this generator works

Two correlated columns are built by the standard construction for a bivariate normal: draw two independent standard normals x and z, then take y as rho times x plus the square root of one minus rho squared, times z. The normals themselves come from Box-Muller over the browser's generator. Damage is applied in a fixed order — duplicates, then outliers, then blanks — so that the blank count is exact rather than approximate. Finally the correlation is measured from the surviving pairs, and the finished dataset is re-read to confirm that every reported figure matches the rows.

Randomness and fairness

The draw is random; the shape is specified. Without a seed it uses the browser's cryptographically secure generator; with a seed a small deterministic one, which is reproducible and therefore explicitly not cryptographically secure. The measured correlation varies between draws even at the same target, which is a property of sampling rather than a defect.

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

Assumptions this tool makes

  • Both columns are drawn from a normal distribution.
  • Correlation means linear Pearson correlation.
  • Rows with a blank in either column are excluded from the correlation measurement.

Limitations and good to know

  • Two numeric columns only. It is not a replacement for the synthetic test data generator, which builds many typed fields.
  • Both columns are normally distributed. Skewed, bounded and count data all behave differently and are not modelled.
  • Correlation here is linear. A strong non-linear relationship can show a Pearson correlation near zero, and this tool cannot produce one.
  • Nothing is stored between visits, so seed anything a test will assert against.

Common mistakes

Expecting the measured correlation to equal the requested one
It never does exactly. A 200-row sample at 0.7 typically measures somewhere around 0.65 to 0.75, and quoting the requested figure in a report would be quoting a number that is not in the data.
Adding blanks and still quoting the original correlation
Dropping incomplete rows changes the sample, so the correlation changes with it. The figure shown is measured after blanking, which is the honest one.
Treating a zero correlation as proof of independence
Pearson correlation only sees straight lines. Two columns can be perfectly related and still measure near zero.

Practical tips

  • Generate the same target at 20 rows and at 500 to show how much the measured figure moves with sample size — it is the clearest demonstration of sampling error there is.
  • For a cleaning pipeline, plant duplicates and outliers together: tools that find one often miss the other.
  • Commit the seed rather than the CSV, so the fixture can be regenerated and reviewed as a diff.

Privacy and your data

The dataset is generated entirely in your browser. Nothing is uploaded, and no seed or generated value is stored between visits.

Frequently asked questions

Why is the measured correlation not the one I asked for?
Because a finite sample drawn from a population with a given correlation has its own, slightly different, sample correlation. The gap shrinks as rows increase. Reporting the request rather than the measurement would be reporting a number the data does not contain.
How is this different from the synthetic test data generator?
That one builds records that look like people, with many typed fields and uniform numbers. This one builds two numeric columns with a controlled statistical shape. Different jobs entirely.
Can I get a negative correlation?
Yes, anywhere from -100% to 100%. Negative correlations are worth testing separately, because a surprising amount of charting code assumes the trend line slopes upward.