C and Python interfaces to compute the autocorrelation vs. lag of a signal.
autocorrelation.c
provides functions to compute the autocorrelation of a signal for the k first lags/delays.
autocorrelation.py
is a python interface for the C code.
The algorithm used is the following:
where is the
point of the signal,
is its length,
is its mean, and
is its variance.
We re-express it as :
with
in order to speed up calculations with simple parallelizable forms for and
and correcting for the induced errors using the relatively simple
and
.
In the case, it falls back to the variance normalized by itself (a.k.a.
1
) and the corrections vanish.
- It can comput the autocorrelations using the whole bytes or for each bits of every byte.
- The whole input file is loaded into memory, but it's otherwise trying to be memory efficient.
MPFR
is used for precision when working with big numbers.openMP
is used for parallelisation; some of the code might be suboptimal for single threaded execution.
Simply execute make all
- To compile a binary:
gcc -O3 autocorrelation.c -o autocorrelation.out -Wall -lmpfr -lgmp -fopenmp
- To compile a shared library:
gcc -O3 -fPIC -shared autocorrelation.c -o autocorrelation.so -Wall -lmpfr -lgmp -fopenmp
For linux, add -DUNIX
.