Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

inconsistency in the algorithm for calculating cross spectral densities #9751

Copy link
Copy link
Closed
@zsoltlazar

Description

@zsoltlazar
Issue body actions

Bug report

Bug summary

In /usr/local/lib/python2.7/dist-packages/matplotlib/mlab.py Welch's periodogramm method is implemented erronously for the case of two time series. For the second time series the order of detrending and windowing are interchanged.

between lines 716 to 728, within the _spectral_helper method

    result = detrend(result, detrend_func, axis=0)    // ZIL comment: detrend first 
    result, windowVals = apply_window(result, window, axis=0,  // ZIL comment: windowing next
                                      return_window=True)      // THIS IS CORRECT!
    result = np.fft.fft(result, n=pad_to, axis=0)[:numFreqs, :]
    freqs = np.fft.fftfreq(pad_to, 1/Fs)[:numFreqs]

    if not same_data:
        # if same_data is False, mode must be 'psd'   
        resultY = stride_windows(y, NFFT, noverlap)
        resultY = apply_window(resultY, window, axis=0)  // ZIL comment: windowing first ????? 
        resultY = detrend(resultY, detrend_func, axis=0) // ZIL comment: detrend next ??????
                                                                  // THIS IS INCORRECT!
        resultY = np.fft.fft(resultY, n=pad_to, axis=0)[:numFreqs, :]
        result = np.conjugate(result) * resultY

Matplotlib version

  • Operating system: Ubuntu 16.04
  • Matplotlib version: 2.0.1
  • Python version: 2.7.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.