MockDataLab
Data & MLNature / JMLR-style referenceseed 11

Synthetic polynomial dataset

The clean column is the cubic 0.18x³ − 1.05x² + 0.4x + 2 on x uniform from −1 to 6, with Gaussian noise of standard deviation 0.7 and seed 11. A straight line through these points is the wrong model on purpose.

Generating polynomial

y = 0.18*x^3 - 1.05*x^2 + 0.4*x + 2

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

What this page generates

Polynomial regression exercises fail in a useful way when the mean bends. This cubic falls through the middle of the interval and rises again toward x = 6. The leading coefficient 0.18 is small, so the bend is gentle rather than a sharp hook. Noise of 0.7 blurs the bend without erasing it. One hundred forty rows are enough to prefer a cubic over a line if the comparison uses held-out error or a simple residual plot.

There is no extra outlier process. Every deviation from the cubic is one normal draw. If a residual plot still shows a smile after a quadratic fit, the cubic term is what remains. If a student centers x before fitting, the coefficients change and the fitted curve should not. That distinction is easier to teach when the generating polynomial is written on the page.

The sample of x is random, so bin means are the honest way to see the bend. The generator does not bin for you. Average y inside intervals of x and you should recover a shape close to the cubic, with more jitter in bins that happened to receive fewer draws.

Generating rule

Generating polynomial

y = 0.18*x^3 - 1.05*x^2 + 0.4*x + 2

Check values

Worked numbers

Seed 11 yields 140 rows. The root-mean-square gap between measured y and the cubic column is 0.761, next to the requested Gaussian standard deviation 0.7. A straight-line fit is the wrong target: the clean column is the cubic written above, not a line.

Parameters and defaults

Parameters, defaults, and what they change
ParameterDefaultRangeEffect
xuniform [−1, 6]finite intervalCovers the dip and the later rise of this cubic.
samples1402 to 20,000Stabilizes bin means and polynomial fits.
Gaussian std0.7≥ 0Vertical scatter around the cubic.
seed11unsigned 32-bitLocks x and the residuals.

Python for this seed

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

reproduce_seed_11.pyseed 11
# 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: 11
# formula: y = 0.18*x^3 - 1.05*x^2 + 0.4*x + 2
# samples: 140

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


SEED = 11
N = 140
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] = (-1.0) + ((6.0) - (-1.0)) * rng()
        y_clean[i] = ((((0.18 * (x[i] ** 3.0)) - (1.05 * (x[i] ** 2.0))) + (0.4 * x[i])) + 2.0)
        noise = 0.0
        noise += (0.7) * box_muller(rng)
        y[i] = y_clean[i] + noise

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

Exercises

  • EXERCISE 01Ask a model-selection lab to choose among degrees 1, 2, and 3.
  • EXERCISE 02Plot residuals from a linear fit and look for remaining curvature.
  • EXERCISE 03Check a numerical pipeline that expands x, x², and x³ without looking at the clean column.

Questions

Is the cubic monic?

No. The x³ coefficient is 0.18, not 1. A monic cubic would be much steeper on this interval.

Why not space x evenly?

Even spacing is a designed experiment. This page imitates a random sample. Switch the distribution in the editor if you want a grid.

Will degree 4 fit better?

In-sample, a higher degree can always wiggle toward noise. The clean column is only degree 3, so extra degrees are fitting the Gaussian draws.

Related

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