Last active
May 2, 2016 16:59
-
-
Save sergeyf/815e16c8940d182264b4595538a65e7e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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