Calculate autocorrelation using FFT in Matlab

Just like you stated, take the fft and multiply pointwise by its complex conjugate, then use the inverse fft (or in the case of cross-correlation of two signals: Corr(x,y) <=> FFT(x)FFT(y)*) x = rand(100,1); len = length(x); %# autocorrelation nfft = 2^nextpow2(2*len-1); r = ifft( fft(x,nfft) .* conj(fft(x,nfft)) ); %# rearrange and keep values corresponding … Read more

pandas columns correlation with statistical significance

To calculate all the p-values at once, you can use calculate_pvalues function (code below): df = pd.DataFrame({‘A’:[1,2,3], ‘B’:[2,5,3], ‘C’:[5,2,1], ‘D’:[‘text’,2,3] }) calculate_pvalues(df) The output is similar to the corr() (but with p-values): A B C A 0 0.7877 0.1789 B 0.7877 0 0.6088 C 0.1789 0.6088 0 Details: Column D is automatically ignored as it … Read more

Pandas Correlation Groupby

You pretty much figured out all the pieces, just need to combine them: >>> df.groupby(‘ID’)[[‘Val1′,’Val2′]].corr() Val1 Val2 ID A Val1 1.000000 0.500000 Val2 0.500000 1.000000 B Val1 1.000000 0.385727 Val2 0.385727 1.000000 In your case, printing out a 2×2 for each ID is excessively verbose. I don’t see an option to print a scalar correlation … Read more

Correlation heatmap

Another alternative is to use the heatmap function in seaborn to plot the covariance. This example uses the Auto data set from the ISLR package in R (the same as in the example you showed). import pandas.rpy.common as com import seaborn as sns %matplotlib inline # load the R package ISLR infert = com.importr(“ISLR”) # … Read more

Use .corr to get the correlation between two columns

Without actual data it is hard to answer the question but I guess you are looking for something like this: Top15[‘Citable docs per Capita’].corr(Top15[‘Energy Supply per Capita’]) That calculates the correlation between your two columns ‘Citable docs per Capita’ and ‘Energy Supply per Capita’. To give an example: import pandas as pd df = pd.DataFrame({‘A’: … Read more

use ggpairs to create this plot

Edit for GGally 1.0.1 Since params is now deprecated, use wrap like so: ggpairs(df[, 1:2], upper = list(continuous = wrap(“cor”, size = 10)), lower = list(continuous = “smooth”)) Original answer Customization of complicated plots is not always available through parameter list. That’s natural: there are way too many parameters to keep in mind. So the … Read more