scrollintoview animation

In most modern browsers (Chrome and Firefox, but not Safari, UC, or IE) you can pass options in an object to .scrollIntoView(). Try this: elm.scrollIntoView({ behavior: ‘smooth’, block: ‘center’ }) Other values are behavior: ‘instant’ or block: ‘start’ or block: ‘end’. See https://developer.mozilla.org/en/docs/Web/API/Element/scrollIntoView

NumPy version of “Exponential weighted moving average”, equivalent to pandas.ewm().mean()

I think I have finally cracked it! Here’s a vectorized version of numpy_ewma function that’s claimed to be producing the correct results from @RaduS’s post – def numpy_ewma_vectorized(data, window): alpha = 2 /(window + 1.0) alpha_rev = 1-alpha scale = 1/alpha_rev n = data.shape[0] r = np.arange(n) scale_arr = scale**r offset = data[0]*alpha_rev**(r+1) pw0 = … Read more

Smooth GPS data

Here’s a simple Kalman filter that could be used for exactly this situation. It came from some work I did on Android devices. General Kalman filter theory is all about estimates for vectors, with the accuracy of the estimates represented by covariance matrices. However, for estimating location on Android devices the general theory reduces to … Read more

Plot smooth line with PyPlot

You could use scipy.interpolate.spline to smooth out your data yourself: from scipy.interpolate import spline # 300 represents number of points to make between T.min and T.max xnew = np.linspace(T.min(), T.max(), 300) power_smooth = spline(T, power, xnew) plt.plot(xnew,power_smooth) plt.show() spline is deprecated in scipy 0.19.0, use BSpline class instead. Switching from spline to BSpline isn’t a … Read more

tech