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
<ludwig.schwa...@gmail.com>wrote:
> Hi,
>
> On Sun, Feb 7, 2010 at 12:46 AM, Ariel Rokem <aro...@berkeley.edu> wrote:
> > 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
>
> I agree. I was hoping the first two lines above would be sufficient.
> Then I saw scaling_factor also included Fs if scaling by frequency,
> and Pxy is of shape (numFreqs,n), i.e. not a straightforward 1-D
> array, which caused me to reserve my judgment a little bit... :-)
>
> > What does become more apparent when I do that is that in frequency bands
> in
> > which the power is rather small, the ratio discrepancies between the mlab
> > result and the matlab result can be rather large, on the order of a
> factor
> > of 2-2.5, even when the differences are tiny. Similarly, when the power
> is
> > rather large, there can be non-negligible differences between the two
> > results. Is there anything to do about that?
>
> Could this be because Matlab uses a Hamming window by default, while
> mlab uses a *Hanning* window by default? Very similar-sounding names,
> and also very similar windows numerically (but not exactly the
> same)...
>
> Ludwig
>
--
Ariel Rokem
Helen Wills Neuroscience Institute
University of California, Berkeley
http://argentum.ucbso.berkeley.edu/ariel
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel