GenerateRandomSearch

Regression Dataset Generator

Testing anything that fits a line needs data whose answer you already know. This builds points from a slope and intercept you choose, adds as much noise as you want, and then fits the line back out — so you can see directly how far the estimate lands from the truth, and how much noise it takes before R-squared stops looking convincing.

What this generator does

Draws x values uniformly, computes y from your slope and intercept, adds Gaussian noise, then runs ordinary least squares over the result. Both the true parameters and the recovered ones are shown, because the gap between them is what estimating from a finite sample actually looks like.

How to use this tool

  1. Set the slope and intercept the data should be built from.
  2. Add noise to scatter the points away from the line.
  3. Generate, then compare the fitted slope against the true one.
  4. Copy the CSV into whatever you are testing.

Understanding the controls

True slope and intercept
The relationship the data is generated from. With zero noise the fit recovers them almost exactly — almost, because values are rounded to two decimals for display and that alone shifts the answer slightly.
Noise
How far points scatter from the line. This is the control worth playing with: it changes R-squared dramatically while leaving the underlying relationship completely intact.
How many rows
Between 10 and 1,000. Small samples give visibly worse estimates, which is the point.
Seed
Any word reproduces the identical dataset, which a committed test fixture needs.

Common use cases

  • Testing a regression implementation against data whose answer is known
  • Showing why R-squared measures scatter rather than whether a relationship exists
  • Producing scatter-plot data with a deliberate trend for a chart component
  • Teaching least squares from data rather than algebra
  • Checking how many points an estimate needs before it settles

How this generator works

Ordinary least squares is computed directly from the generated rows rather than remembered from the construction, so the reported fit is a genuine measurement of the data you are given. R-squared is the squared correlation between x and y.

Randomness and fairness

The x values and the noise are random, so two runs differ. The slope you specify does not. Seeded runs are reproducible and therefore explicitly not cryptographically secure; unseeded runs 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

  • One predictor only. Multiple regression, interactions and non-linear terms are not covered.
  • Noise is Gaussian and constant across the range. Real data often has noise that grows with x, which breaks a key regression assumption this cannot demonstrate.
  • Values are rounded to two decimals for display, so a perfect fit is very slightly imperfect.
  • Datasets are not saved; seed anything a test asserts against.

Privacy and your data

The dataset is generated in your browser. No parameters, seeds or generated rows are transmitted or kept after you close the page.