Skip to content

Reproducible synthetic linear data

Question

Generate a reproducible synthetic regression dataset with independent Gaussian features and independent Gaussian noise. Keep the RNG local to the function.

Short answer

Use an explicit local generator seeded by the caller. The signal and noise draws come from that generator, avoiding dependence on global RNG state. Record the data-generating assumptions when using the dataset for tests.

Original question and answer written by SelfMadeQuant.com.

See the hint and the full worked solution in the question bank (free account).

Open the worked solution

Lessons behind this question

Start with a free lesson: Normal Distribution is part of a free topic. Create a free account, no card needed, to read it in full with worked solutions.

Read it free