erlab.analysis.correlation¶
Macros for correlation analysis.
Functions
|
Calculate the autocorrelation function (ACF) of a 2D array including nans. |
|
|
|
Calculate the autocorrelation of a N-dimensional array, normalized to 1. |
|
|
|
|
|
Perform 1-dimensional correlation analysis on |
- erlab.analysis.correlation.acf2(arr, mode='full', method='fft')[source]¶
Calculate the autocorrelation function (ACF) of a 2D array including nans.
- Parameters:
arr – The input array for which the ACF needs to be calculated.
mode (str) – The mode of the ACF calculation, by default
"full"
. For more information, seescipy.signal.correlate
.method (str) – The method used for ACF calculation, by default
"fft"
. For more information, seescipy.signal.correlate
.
- Returns:
The ACF of the input array.
- Return type:
Examples
>>> import numpy as np >>> import xarray as xr >>> np.random.seed(0) # Set the random seed for reproducibility >>> arr = xr.DataArray(np.random.rand(10, 10), dims=("kx", "ky")) >>> acf = acf2(arr) >>> acf <xarray.DataArray (qx: 19, qy: 19)> Size: 3kB 8.403e-05 0.01495 0.01979 0.02734 0.03215 ... 0.02734 0.01979 0.01495 8.403e-05 Coordinates: * qx (qx) int64 152B -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 * qy (qy) int64 152B -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9
- erlab.analysis.correlation.xcorr1d(in1, in2, method='direct')[source]¶
Perform 1-dimensional correlation analysis on
xarray.DataArray
s.