MockDataLab
Data & MLNature / JMLR-style referenceseed 42

Synthetic quadratic dataset

This page draws x from a uniform interval and sets the clean response to 3x² + sin(x), then adds Gaussian noise and a few deliberate spikes. Seed 42 rebuilds the same 180-row table. The file is synthetic experimental data, not a laboratory record.

Clean response

y = 3*x^2 + sin(x)

Static snapshotCSV (seed 42) ↓
Interactive dataset studio loads as it enters view…

What this page generates

A quadratic specimen is useful when a lesson needs a curved mean and a known equation. Here the mean is dominated by 3x², so the graph is a parabola opening upward. The sine term is a small wiggle on that bowl. Between x = −2 and x = 2 the square term runs from 0 to 12, while sin(x) stays inside −1 to 1, so the wiggle never hides the parabola. Students can see both pieces if they plot the clean column beside the noisy column.

Noise is Gaussian with standard deviation 1.1. That is large enough to scatter points off the curve and small enough that the bowl is still obvious. On top of that, each row has a 4 percent chance of an extra spike of size 6, with a random sign. Those spikes are outliers, not a second noise distribution mixed into every row. A robust fit should ignore them; an ordinary least-squares fit will be tugged toward them. Because the chance and the size are written into the file header, a reader can count how many rows were actually spiked.

x itself is not evenly spaced in the table, because each x is an independent uniform draw. Sorting by x makes the curve readable; the row order is the order the seeded generator produced. The same seed, formula, range, noise, and sample count reproduce the table in the browser and in the Python script. Changing the seed changes the draws. Changing the formula changes the mean. Neither change turns the file into a measurement.

Generating rule

Clean response

y = 3*x^2 + sin(x)

Check values

Worked numbers

With seed 42 the first draw is x = 0.4044. The clean value 0.8841 matches 3x² + sin(x) at that x. The measured value is 1.7205. Across 180 rows, 7 differ from the clean column by more than 4, which is the neighborhood of the size-6 spikes.

Parameters and defaults

Parameters, defaults, and what they change
ParameterDefaultRangeEffect
xuniform [−2, 2]any finite interval with max > minMoves the sample along the parabola. The ends reach about y = 12.
samples1802 to 20,000More rows tighten a fit and lengthen the file.
Gaussian std1.10 or greaterSpreads measured y around the clean curve.
outlier fraction0.040 to 1Share of rows that also receive a spike.
outlier size60 or greaterAbsolute size of each spike, added with a random sign.
seed420 to 4294967295Fixes the uniform draws, the noise, and the spikes.

Python for this seed

Full script with mulberry32() & box_muller() available via Copy Python above

reproduce_seed_42.pyseed 42
# SYNTHETIC DATA - generated by MockDataLab (mockdatalab.com)
# This file is synthetic and must not be presented as real measurements, clinical data, or results from a physical instrument.
# generator: function-relation
# seed: 42
# formula: y = 3*x^2 + sin(x)
# samples: 180

# mulberry32() and box_muller() are included when you copy the full script.


SEED = 42
N = 180
rng = mulberry32(SEED)

x = np.empty(N, dtype=np.float64)
y_clean = np.empty(N, dtype=np.float64)
y = np.empty(N, dtype=np.float64)

for i in range(N):
        x[i] = (-2.0) + ((2.0) - (-2.0)) * rng()
        y_clean[i] = ((3.0 * (x[i] ** 2.0)) + math.sin(x[i]))
        noise = 0.0
        noise += (1.1) * box_muller(rng)
        if rng() < 0.04:
            noise += (-1.0 if rng() < 0.5 else 1.0) * (6.0)
        y[i] = y_clean[i] + noise

columns = ["x","y_clean","y"]
data = np.column_stack([x, y_clean, y])

Exercises

  • EXERCISE 01Show a class the difference between the clean parabola and the column a noisy instrument would have written.
  • EXERCISE 02Practice outlier rules: with this fraction and magnitude, only a handful of rows should sit far from the bowl.
  • EXERCISE 03Test a plotting pipeline that must sort random x before it draws a line.

Questions

Why is the sine term hard to see?

On this interval 3x² is about ten times larger than sin(x). The sine is still in the clean column. Subtract 3x² from y_clean if you want to inspect it alone.

Are the x values a grid?

No. Each x is drawn independently from Uniform(−2, 2). Two rows can land very close together, and the table is not sorted.

Does the outlier replace the Gaussian noise?

No. The spike is added after the Gaussian draw. A spiked row is clean value plus Gaussian noise plus ±6.

Can I publish this table as experimental data?

No. The header says SYNTHETIC DATA - generated by MockDataLab (mockdatalab.com). Leave that banner on the file.

Related

SYNTHETIC DATA - generated by MockDataLab (mockdatalab.com). Do not present the download as a real measurement.