psambit9791 / jdsp

A Java Library for Digital Signal Processing
https://jdsp.dev
MIT License
240 stars 45 forks source link

Auto-Correlation #16

Closed leeytsang closed 3 years ago

leeytsang commented 3 years ago

I want to calculate signal's Auto-Correction. In matlib, I can use xcorr() function to do this. But this this lib, I can not find a function like this. (Cross-Correction can do this?)

psambit9791 commented 3 years ago

As of now, the autocorrelation isn't supported as a single function. I'll add this functionality in the next release.

Fix for now: To use CrossCorrelation to compute the autocorrelation, you need to pass the signal twice. First being the actual signal, and the second being the window which in this case is again the signal.

psambit9791 commented 3 years ago

I have seen the code and have identified an issue due to which the autocorrelation cannot be computed at the moment. It is because of a constraint on the window length that has been put in the CrossCorrelation class. I will add a fix ASAP.

psambit9791 commented 3 years ago

Fixed in ea964774c780a712ee3049138d0b7f52f68c6b14 Added an additional constructor for CrossCorrelation which takes only the signal as argument. Calling crossCorrelate() on objects created using that constructor computes the autocorrealtion.