How to interpret the values returned by numpy.correlate and numpy.corrcoef?

numpy.correlate simply returns the cross-correlation of two vectors. if you need to understand cross-correlation, then start with http://en.wikipedia.org/wiki/Cross-correlation. A good example might be seen by looking at the autocorrelation function (a vector cross-correlated with itself): import numpy as np # create a vector vector = np.random.normal(0,1,size=1000) # insert a signal into vector vector[::50]+=10 # perform … Read more

scipy, lognormal distribution – parameters

The distributions in scipy are coded in a generic way wrt two parameter location and scale so that location is the parameter (loc) which shifts the distribution to the left or right, while scale is the parameter which compresses or stretches the distribution. For the two parameter lognormal distribution, the “mean” and “std dev” correspond … Read more

`ValueError: A value in x_new is above the interpolation range.` – what other reasons than not ascending values?

If you are running Scipy v. 0.17.0 or newer, then you can pass fill_value=”extrapolate” to spi.interp1d, and it will extrapolate to accomadate these values of your’s that lie outside the interpolation range. So define your interpolation function like so: intfunc = spi.interp1d(coarsex, coarsey,axis=0, fill_value=”extrapolate”) Be forewarned, however! Depending on what your data looks like and … Read more

Plot a plane based on a normal vector and a point in Matlab or matplotlib

For all the copy/pasters out there, here is similar code for Python using matplotlib: import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D point = np.array([1, 2, 3]) normal = np.array([1, 1, 2]) # a plane is a*x+b*y+c*z+d=0 # [a,b,c] is the normal. Thus, we have to calculate # d and we’re … Read more