Re: [matplotlib-devel] Comparison of mlab.csd and Matlab's cpsd

2010-02-09 Thread Ariel Rokem
Hi - mea culpa - as pointed out by a colleague (and documented in the help document for "hanning" in Matlab), this function produces the same window, but without the first and last zero-weighted samples. Cheers -- Ariel On Tue, Feb 9, 2010 at 4:58 PM, Ariel Rokem wrote: > Hi everyone, > > Myste

Re: [matplotlib-devel] Comparison of mlab.csd and Matlab's cpsd

2010-02-09 Thread Ariel Rokem
Hi everyone, Mystery solved (I think)! It turns out that matlab has two functions, one called "hann" and the other called "hanning". They both purport to produce the hanning window, but they produce two (slightly) different things. Only one of these (the one given by "hann") actually produces the

Re: [matplotlib-devel] Comparison of mlab.csd and Matlab's cpsd

2010-02-08 Thread Ariel Rokem
Hi - the maximal difference in this case is of about 6 (units?), which is an approximately 50% difference. This is in one point in the spectrum which has a relatively small value - the maximal peaks in the spectra are on the order of 1200, so in the grand scheme of things, not that horrible. Other

Re: [matplotlib-devel] Comparison of mlab.csd and Matlab's cpsd

2010-02-07 Thread Ariel Rokem
Hi Ludwig (responding also to list), I don't think that the cause of the discrepancy is because of the hamming/hanning window difference. I do set the window in the matlab part to also be a hanning window of length nfft. Cheers, Ariel On Sun, Feb 7, 2010 at 7:45 AM, Ludwig Schwardt wrote: > H

Re: [matplotlib-devel] Comparison of mlab.csd and Matlab's cpsd

2010-02-06 Thread Ariel Rokem
Hi - thanks Ludwig. I don't think that a major reworking of the logic of the function is needed. Simply replacing the line you mentioned with: Pxy *= 1 / (np.abs(windowVals)**2).sum() Pxy[1:-1] *= scaling_factor if scale_by_freq: Pxy[[0,-1]] /= Fs seems to solve the 0 and NFF

Re: [matplotlib-devel] Comparison of mlab.csd and Matlab's cpsd

2010-02-05 Thread Ludwig Schwardt
Hi, > From: Ariel Rokem > However - two elements are off by a factor of approximately 2 - the > very first element and the very last. ... Does anyone have any idea > why this would be the case? >From a quick look at the mlab code, it looks like a bug in mlab._spectral_helper. The default spectr

[matplotlib-devel] Comparison of mlab.csd and Matlab's cpsd

2010-02-04 Thread Ariel Rokem
Hi everyone, Revisiting an issue which has already been discussed previously - in order to check whether mlab.csd really does exactly what Matlab's cpsd is doing, we wrote a couple of scripts, one in matlab and one in Python. They both run on the attached data. The comparison of the results show t