Provides a multiple-τ algorithm for Python 2.7 and Python 3.x and requires the package numpy.
Multipe-τ correlation is computed on a logarithmic scale (less data points are computed) and is thus much faster than conventional correlation on a linear scale such as numpy.correlate().
Recommended literature:
The source code of multipletau is available at https://github.com/paulmueller/multipletau.
Autocorrelation of a 1-dimensional sequence on a log2-scale.
This computes the correlation according to numpy.correlate() for positive \(k\) on a base 2 logarithmic scale.
numpy.correlate(a, a, mode=”full”)[len(a)-1:]
\(z_k = \Sigma_n a_n a_{n+k}\)
Note that only the correlation in the positive direction is computed.
Parameters: | a : array_like
m : even integer
deltat : float
normalize : bool
copy : bool
dtype : dtype, optional
|
---|---|
Returns: | autocorrelation : ndarray
|
Notes
The algorithm computes the correlation with the convention of the curve decaying to zero.
For experiments like e.g. fluorescence correlation spectroscopy, the signal can be normalized to M-k by invoking:
normalize = True
For emulating the numpy.correlate behavior on a logarithmic scale (default behavior) use:
normalize = False
Examples
>>> from numpy import dtype
>>> from multipletau import autocorrelate
>>> autocorrelate(range(42), m=2, dtype=dtype(float))
array([[ 1.00000000e+00, 2.29600000e+04],
[ 2.00000000e+00, 2.21000000e+04],
[ 4.00000000e+00, 2.03775000e+04],
[ 8.00000000e+00, 1.50612000e+04]])
Cross-correlation of two 1-dimensional sequences on a log2-scale.
This computes the cross-correlation according to numpy.correlate() for positive \(k\) on a base 2 logarithmic scale.
numpy.correlate(a, v, mode=”full”)[len(a)-1:]
\(z_k = \Sigma_n a_n v_{n+k}\)
Note that only the correlation in the positive direction is computed.
Parameters: | a, v : array_like
m : even integer
deltat : float
normalize : bool
copy : bool
dtype : dtype, optional
|
---|---|
Returns: | crosscorrelation : ndarray
|
Notes
The algorithm computes the correlation with the convention of the curve decaying to zero.
For experiments like e.g. fluorescence correlation spectroscopy, the signal can be normalized to M-k by invoking:
normalize = True
For emulating the numpy.correlate behavior on a logarithmic scale (default behavior) use:
normalize = False
Examples
>>> from numpy import dtype
>>> from multipletau import correlate
>>> correlate(range(42), range(1,43), m=2, dtype=dtype(float))
array([[ 1.00000000e+00, 2.38210000e+04],
[ 2.00000000e+00, 2.29600000e+04],
[ 4.00000000e+00, 2.12325000e+04],
[ 8.00000000e+00, 1.58508000e+04]])
Convenience function that wraps around numpy.correlate and returns the data as multipletau.correlate does.
Parameters: | a, v : array_like
deltat : float
normalize : bool
copy : bool
dtype : dtype, optional
|
---|---|
Returns: | crosscorrelation : ndarray
|
This module is used for testing the multiple-tau algorithm. Executing this module as a package by invoking
python -m test
creates plots that illustrate the difference between multipletau.correlate() and numpy.correlate().
Generate exponentially correlated noise.
Parameters: | N : integer
tau : float
variance : float
deltat : float
|
---|---|
Returns: | a : ndarray
|
Generate exponentially cross-correlated noise.
Parameters: | N : integer
tau : float
variance : float
deltat : float
|
---|---|
Returns: | a, randarray : ndarrays
|