Skip to content

Auto-correlation in Python #11

@mobias17

Description

@mobias17

Hi @taspinar ,

in http://ataspinar.com/2018/04/04/machine-learning-with-signal-processing-techniques/ auto correlation is based on Numpy, what is totally fine. Also searched for ACF and PCF toolkits and I wanted to point you direction statsmodels.

e.g.

from statsmodels.graphics.tsaplots import plot_acf
from statsmodels.tsa.stattools import acf

plt.plot(t_values,acf(composite_y_value, nlags=N,fft=True),linestyle='-', color='blue')
plt.xlabel('time delay [s]')
plt.ylabel('Autocorrelation amplitude')
plt.show()

plot_acf(composite_y_value,zero=True, lags=N-1)

This returns plots with ACF between -1 and 1, what I would rather expect. Not sure why numpy has this scaling, that is weird to me at least in terms of correlation.

Further, statsmodels.tsa.stattools.acf has a fft parameter that you are refering in your fun fact. Very interesting. Maybe you could elaborate on the transformation between FFT, PSD and the auto-correlation if ever you are making adjustments.

Great blog!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions