Statistics
CrossCorrelation
compute sample cross-correlations of two time series
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
CrossCorrelation(X1, X2)
CrossCorrelation(X1, X2, lags)
X1, X2
-
discrete univariate time series given as Vectors, lists, Matrices with one column, or TimeSeries objects with one dataset.
lags
(optional) maximal lag to return, or a range of lags to return. By default all possible lags are returned.
scaling
One of biased, unbiased, or none. Default is none. scaling=biased computes Rk=Ckn. scaling=unbiased scales each Ck by 1n−k.
raw
If this option is given, the output is not normalized so that the middle entry (corresponding to R0) is 1 when scaling=unbiased or scaling=none.
For a discrete time series X1 and X2, the CrossCorrelation command computes the cross-correlations Rk=CkC0 where Ck=∑t=1n−k⁡X1t⁢X2t+k&conjugate0; for k=−n+1..n−1.
For efficiency, all of the lags are computed at once using a numerical discrete Fourier transform. Therefore all data provided must have type complexcons and all returned solutions are floating-point, even if the problem is specified with exact values.
If the inputs are not the same length, the shorter is padded with zeros at the end.
Note: CrossCorrelation makes use of DiscreteTransforms[FourierTransform] and thus will work strictly in hardware precision, that is, its accuracy is independent of the setting of Digits.
For more time series related commands, see the TimeSeriesAnalysis package.
with(Statistics):
CrossCorrelation(<1,2,1,2>,<1,2,1,2>);
0.2000000000622400.5000000000305990.5999999999867191.0.5999999999867190.5000000000305990.200000000062240
CrossCorrelation(<1,2,1,2>,<1,2,1,2>, 2);
0.5000000000305990.5999999999867191.0.5999999999867190.500000000030599
CrossCorrelation(<1,2,1,2>,<1,2,1,2>, -2..2 );
CrossCorrelation(<1,2,1,2>,<1,2,1,2>, 2, scaling=unbiased );
1.000000000061200.7999999999822921.0.7999999999822921.00000000006120
CrossCorrelation(<1, 2, 3>,<4, 5>);
0.8571428571961741.642857142967681.0.3571428571743542.32142559164592⁢10−11
CrossCorrelation(<1, 2, 3>,<4, 5, 0>);
CrossCorrelation(<4, 5>,<1,2,3>);
2.32142559164592⁢10−110.3571428571743541.1.642857142967680.857142857196174
CrossCorrelation(<4, 5, 0>,<1,2,3>);
The CrossCorrelation command also accepts TimeSeries objects, but the date information is ignored.
t1 := TimeSeriesAnalysis:-TimeSeries([4, 5, 0], enddate="2012-01-01", frequency="monthly");
t1≔Time seriesdata set3 rows of data:2011-11-01 - 2012-01-01
t2 := TimeSeriesAnalysis:-TimeSeries([1, 2, 3], enddate="2015-09-30", frequency="daily");
t2≔Time seriesdata set3 rows of data:2015-09-28 - 2015-09-30
CrossCorrelation(t1, t2);
t3 := TimeSeriesAnalysis:-TimeSeries([[4,5,0], [1,2,3]], headers=["Sales", "Profits"], enddate="2013-05-01", frequency="weekly");
t3≔Time seriesSales, Profits3 rows of data:2013-04-17 - 2013-05-01
CrossCorrelation(t3[.., "Sales"], t3[.., "Profits"]);
CrossCorrelation can be used to create cross-correlograms
L := LinearAlgebra:-RandomVector(1000, datatype=float):
S := CrossCorrelation(1/3*(2*L[101..1000]+L[51..950]),L[1..900], 150, scaling=unbiased, raw):
ColumnGraph(S, offset=-151, color="Gray", style=polygon);
The Statistics[CrossCorrelation] command was introduced in Maple 15.
For more information on Maple 15 changes, see Updates in Maple 15.
The Statistics[CrossCorrelation] command was updated in Maple 2015.
The X1 parameter was updated in Maple 2015.
See Also
ColumnGraph
Statistics[AutoCorrelation]
TimeSeriesAnalysis
Download Help Document
What kind of issue would you like to report? (Optional)