Skip to content

Instantly share code, notes, and snippets.

@sergeyf
Last active May 2, 2016 16:59
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 sergeyf/815e16c8940d182264b4595538a65e7e to your computer and use it in GitHub Desktop.
Save sergeyf/815e16c8940d182264b4595538a65e7e to your computer and use it in GitHub Desktop.
import numpy as np
def f_of_x(X,w):
n,d = X.shape
X_dot_w = np.dot(X,w)
y = np.zeros(n)
# the inner product goes through a sin
# or a cos, depending on simple condition
cos_flag = X[:,0] < 0.0
sin_flag = ~cos_flag
y[cos_flag] = np.cos(X_dot_w[cos_flag])
y[sin_flag] = np.sin(X_dot_w[sin_flag])
return y
# generate some simulated data
d = 10
n = 100000
w = np.random.rand(d)
X = np.random.randn(n,d)
y = f_of_x(X,w)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment