-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
The implementation is not correct. It reads
d = X.shape[0]
for i in range(0,d):
res = np.prod(np.sum([i * np.cos((j+1)*X[i] + j) for j in range(1, 5+1)]))
return resI'm guessing the intention was
d = X.shape[0]
res = np.prod([
np.sum([i * np.cos((j+1)*X[i] + j) for j in range(1, 5+1)]))
for i in range(d)
])
return resI suggest the following implementation which avoids loops (inefficient in numpy), and is IMO more readable (it does allocate a bigger array)
def f(self, X):
j = np.arange(1, 6)[None, :]
res = np.cos((j + 1) * X[:, None] + j) \
.sum(axis=1) \
.prod()
return resReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels