Skip to content

Instantly share code, notes, and snippets.

@benoitdescamps
Last active January 5, 2023 14:16
Show Gist options
  • Save benoitdescamps/c36319ea11cb9981980abfa16a523d6f to your computer and use it in GitHub Desktop.
Save benoitdescamps/c36319ea11cb9981980abfa16a523d6f to your computer and use it in GitHub Desktop.
import numpy as np
np.random.seed(1)
def f(x):
"""The function to predict."""
return x *np.sin(x)
#----------------------------------------------------------------------
# First the noiseless case
X = np.atleast_2d(np.random.uniform(0, 10.0, size=100)).T
X = X.astype(np.float32)
# Observations
y = f(X).ravel()
dy = 1.5 + 1.0 * np.random.random(y.shape)
noise = np.random.normal(0, dy)
y += noise
y = y.astype(np.float32)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment