AutoCorrelate
Advanced Analysis Library Only
AnalysisLibErrType AutoCorrelate (double inputArray[], ssize_t sizeOfInputArray, int normalization, double outputArray[]);
Purpose
Finds the autocorrelation of the input array. The autocorrelation Rxx(t) of a function x(t) is defined as the following:
where the symbol denotes correlation.
For the discrete implementation of this function, let Y represent a sequence whose indexing can be negative, let N be the number of elements in the input sequence inputArray, and assume that the indexed elements of inputArray that lie outside its range are equal to zero, as shown in the following relationship:
xj = 0 , j < 0 or j ≥ N
Then AutoCorrelate obtains the elements of Y using the following equation:
for j = -(N–1), -(N–2), ..., -1, 0, 1, ..., (N–2), (N–1)
The elements of the output sequence outputArray are related to the elements in the sequence Y by
Rxxi = yi-(N–1)
for i = 0, 1, 2, ..., 2N–2
Notice that the number of elements in the output sequence outputArray is 2N–1. Because you cannot use negative numbers to index LabWindows/CVI arrays, the corresponding correlation value at t = 0 is the Nth element of the output sequence outputArray. Therefore, outputArray represents the correlation values that AutoCorrelate shifts N times in indexing.
In order to make the autocorrelation calculation more accurate, normalization is required in some situations. This function provides biased and unbiased normalization.
-
Biased normalization
If normalization is ALGORITHM_CONCOR_BIASED_NORMALIZATION, LabWindows/CVI applies biased normalization as follows:
for j = -(N–1), -(N–2), ..., -1, 0, 1, ... (N–2), (N–1), and
Rxx(biased) = yi-(N–1)
for i = 0, 1, 2, ..., 2N–2
-
Unbiased normalization
If normalization is ALGORITHM_CONCOR_UNBIASED_NORMALIZATION, LabWindows/CVI applies unbiased normalization as follows:for j = -(N–1), -(N–2), ..., -1, 0, 1, ..., (N–2), (N–1), and
Rxx(unbiased) = yi-(N–1)
for i = 0, 1, 2, ..., 2N–2
![]() |
Note This function temporarily allocates memory for use as a work area. If AutoCorrelate cannot allocate memory, the function returns an error code. |
Example Code
/* Generate one array with random numbers and find its autocorrelation. */
double x[256], rxx[512];
int n;
n = 256;
Uniform (n, 17, x);
AutoCorrelate (x, n, ALGORITHM_CORCOR_NO_NORMALIZATION, rxx);
Parameters
Input | ||||||||||||||
Name | Type | Description | ||||||||||||
inputArray | double [] | The input array for which to compute the autocorrelation operation. | ||||||||||||
sizeOfInputArray | ssize_t | Number of elements in inputArray. | ||||||||||||
normalization | int | Specifies the normalization method to use to compute the autocorrelation of inputArray. normalization must be one of the following values:
|
||||||||||||
Output | ||||||||||||||
Name | Type | Description | ||||||||||||
outputArray | double [] | The autocorrelation of inputArray. This array must be at least (2n – 1) elements long. |
Return Value
Name | Type | Description |
status | AnalysisLibErrType | A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants. |
Additional Information
Library: Advanced Analysis Library
Include file: analysis.h
LabWindows/CVI compatibility: LabWindows/CVI 2012 and later