Outlier Dataset Generator
Testing an outlier rule needs data where you know which points are genuinely anomalous — otherwise you can only check that it flags something. Here the contaminated points are labelled, and the interquartile rule is run against them, reporting both numbers that matter: how many planted outliers it caught, and how many ordinary points it wrongly flagged. The planted points sit far enough out that the first is nearly always all of them; the second is the one to watch, usually zero in a small sample and usually not in a large one.
What this generator does
Draws a normal sample around 50 and moves a chosen share of points far outside it, keeping their positions labelled. It then applies the interquartile rule — 1.5 times the interquartile range beyond each quartile — and scores it against the truth.
How to use this tool
- Choose how many rows and what share should be contaminated.
- Look at the fences the interquartile rule computes.
- Compare what it caught against what was planted.
- Note the false positives — ordinary points beyond the fences.
Understanding the controls
- How many rows
- Between 20 and 500 values drawn around a mean of 50.
- Contamination (%)
- What share of points are deliberately moved far from the bulk. Higher contamination shifts the quartiles themselves, which makes detection harder rather than easier.
- Seed
- Reproduces the same sample and the same contaminated positions.
Worked examples
- 30 rows, 10% contamination, seeded "demo"
- 3 points were deliberately placed far from the bulk (centred around 50). The interquartile rule flags anything outside 17.06 to 83.56, catching all 3 planted outliers and no ordinary point. That is the usual result at this size: over 400 seeded runs of 30 rows, about one in five flagged an ordinary point, against about half at 120 rows and four in five at 500 rows, both at 5% contamination. None of those runs missed a planted point.
Common use cases
- Scoring an anomaly detection rule against known ground truth
- Showing that the interquartile rule flags ordinary points as well as planted ones
- Test data for a data-cleaning pipeline
- Teaching where box plot whiskers come from
- Reproducing the same contaminated sample from a seed
How this generator works
The fences come from the quartiles of the contaminated data, not the clean data — which is the realistic case and the reason heavy contamination hides itself. The check confirms the flagged list follows exactly from the fences, and that the caught and false-positive counts add up to the flagged total.
Randomness and fairness
The sample and where the outliers land are random; the detection rule is deterministic. Seeded datasets reproduce and are therefore explicitly not cryptographically secure, and unseeded ones 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 variable only — multivariate outliers can be perfectly ordinary in each dimension separately.
- Only the interquartile rule is scored; z-scores and model-based methods behave differently.
- Outliers are placed far out, so they are easier to find than borderline real ones.
- The underlying distribution is normal, which flatters the rule.
- Contaminated samples are not kept; seed one to score a rule twice on it.
Privacy and your data
The sample and the detection run entirely in your browser. No value is transmitted or retained; what is measured is that a sample was made and how many rows it has.
Frequently asked questions
- Why does the interquartile rule flag ordinary points as outliers?
- Because the fences are set at a fixed distance (1.5 times the interquartile range) from the middle 50% of the data, and in any finite sample some perfectly ordinary points will, by chance, land beyond that distance — especially as sample size grows. This is a real, expected false-positive rate baked into the rule, not a flaw in this particular dataset.
- Why are the fences computed from the contaminated data instead of the clean data?
- Because that's the realistic situation: in practice you never have the clean data to compute fences from, only what you were actually given, outliers included. Heavy contamination shifts the quartiles themselves, which is exactly why detection gets harder rather than easier as the contamination rate rises — a genuine limitation of the rule that comparing against clean-data fences would hide.
Related generators
- Missing Data GeneratorDatasets with gaps under all three mechanisms — completely at random, dependent on a column you can see, and dependent on the missing value itself.
- Logistic Regression Dataset GeneratorTwo-feature classification data with a known decision boundary, and the majority-class baseline any model must beat.
- Correlation Matrix GeneratorCorrelation matrices built from a factor model, so they are positive semi-definite — which hand-picked numbers usually are not.
- Synthetic Test Data GeneratorBuild a whole table of fictional records from the fields you choose, then export them as a table, JSON, CSV or SQL inserts.
- Benford's Law CheckerCompares the leading digits of your numbers against Benford's law with a chi-square test, and is clear about what a poor fit does not prove.