Heteroskedastic Data Generator
Ordinary least squares assumes the noise around the line is the same size everywhere. When it is not, the slope estimate stays unbiased — but its standard error does not, so the confidence interval and every p-value built on it are wrong. That failure is invisible in a regression table and obvious in a residual plot, which is exactly why this dataset is worth being able to generate deliberately.
What this generator does
Spreads x evenly across a range and draws y from a straight line plus normal noise whose size grows in proportion to x. It fits the line by least squares, computes the residuals, and measures their standard deviation separately in the lowest and highest third of x so the growth in spread can be read as a ratio.
How to use this tool
- Choose a row count and how fast the noise should grow with x.
- Generate, and compare the residual spread at the low end with the high end.
- Set the growth to zero for a well-behaved comparison dataset.
- Plot y against x elsewhere and look for the fan shape.
Understanding the controls
- How many rows
- Between 20 and 400. The spread is measured on the outer thirds, so more rows make that measurement steadier.
- How fast the noise grows
- Zero gives constant variance — the well-behaved case. Higher values make the fan shape unmistakable.
- Seed
- Any word reproduces the same dataset and the same fit.
Common use cases
- Teaching why a residual-versus-fitted plot is worth drawing
- Demonstrating that unbiased estimates can still have wrong standard errors
- Test data for a robust standard error or weighted least squares implementation
- Showing what non-constant variance actually looks like
- Setting the same dataset twice from a seed
How this generator works
The noise multiplier rises linearly with x, so points on the right scatter further from the line than points on the left while the line itself is unchanged. Least squares is computed from the standard formulas and re-derived from the finished rows before display. The spread ratio divides the residual standard deviation in the top third by the bottom third, which is the same comparison a Goldfeld–Quandt test formalises.
Randomness and fairness
The noise is random; the slope, the residuals and both spreads are computed from the finished dataset. A seed reproduces the data 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
- Variance grows linearly with x; other patterns of non-constant variance behave differently.
- No formal test statistic is reported — the spread ratio is a description, not a p-value.
- The true slope is fixed at 1 so the recovered estimate is easy to judge.
- Errors are normal apart from the changing scale, so this isolates heteroskedasticity from other violations.
- Nothing survives closing the page, so copy the data or the seed.
Privacy and your data
The dataset and the fit are computed entirely in your browser. Nothing about the data or your seed is transmitted or kept.
Related generators
- Regression Dataset GeneratorData built from a slope and intercept you choose, with the line fitted back out of it so you can see how close estimation gets.
- ANOVA Dataset GeneratorGrouped data with a known separation, and the full ANOVA table whose sums of squares are checked to split exactly.
- Outlier Dataset GeneratorContaminated samples where the planted outliers are labelled, so a detection rule can be scored on both kinds of error.
- Autocorrelated Series GeneratorTime series with a chosen serial correlation, showing the measured lag-1 correlation against the process value and what differencing does to it.