forrestbao / pyeeg

Python + EEG/MEG = PyEEG
GNU General Public License v3.0
241 stars 85 forks source link

Optimize LLE function #13

Closed bnaul closed 8 years ago

bnaul commented 8 years ago

Replace for loop implementation with equivalent numpy array operations to speed up computation.

x = np.random.seed(10); x = np.cumsum(np.random.normal(size=4096))

In [419]: %time pyeeg.LLE(x, 2, 4, 1, 1) #  new
CPU times: user 2.73 s, sys: 1.03 s, total: 3.76 s
Wall time: 3.77 s
Out[419]: -0.0001415554

In [421]: %time pyeeg.LLE(x, 2, 4, 1, 1) #  old
CPU times: user 2min 26s, sys: 399 ms, total: 2min 26s
Wall time: 2min 27s
Out[421]: -0.0001415554