Skip to content

Instantly share code, notes, and snippets.

@SwampThingPaul
Forked from RyotaBannai/sample_data_tls.py
Created January 3, 2019 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SwampThingPaul/0ad633d1912fb918b98f7e2ecb5d461a to your computer and use it in GitHub Desktop.
Save SwampThingPaul/0ad633d1912fb918b98f7e2ecb5d461a to your computer and use it in GitHub Desktop.
N=60
mu=0
sd=2
np.random.seed(0)
ran = np.random.normal(size=N)
error1 = sd**2 * ran + mu
error2 = sd*.5 * ran + mu
lin = np.linspace(-15., 15., num=N)
data = lin + error2
data_true = lin
true_func = lambda x, e: .1*x + .1*x**2 + e
x = np.vstack((data, data**2)).T
y_true = np.array([true_func(d, 0) for d in data_true])
y_data = np.array([true_func(d, e) for d,e in zip(data, error1)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment