AutoCorrelation - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.

Online Help

All Products    Maple    MapleSim


Statistics

  

AutoCorrelation

  

compute sample autocorrelations of a real Vector

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

Calling Sequence

AutoCorrelation(X)

AutoCorrelation(X, lags)

Parameters

X

-

discrete univariate real time series given as a Vector, list, DataSeries object, Matrix with one column, DataFrame with one column, or TimeSeries object with one dataset.

lags

-

(optional) maximal lag to return, or a range of lags to return. By default all possible lags are returned.

Options

• 

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 first entry is 1 when scaling=unbiased or scaling=none.

Description

• 

For a discrete time series X, the AutoCorrelation command computes the autocorrelations Rk=CkC0 where Ck=∑t=1n−k⁡Xt−μ⁢Xt+k−μ for k=0..n−1 and  μ is the mean of X.

• 

For efficiency, all of the lags are computed at once using a numerical discrete Fourier transform.  Therefore all data provided must have type realcons and all returned solutions are floating-point, even if the problem is specified with exact values.

• 

Note: AutoCorrelation makes use of DiscreteTransforms[FourierTransform] which works strictly in hardware precision, and thus the accuracy of the autocorrelation is not purely determined by the setting of Digits.

• 

For more time series related commands, see the TimeSeriesAnalysis package.

Examples

> 

with⁡Statistics:

> 

AutoCorrelation⁡1,2,1,2,1,2,1,2

1.−0.8750000000090560.750000000020185−0.6250000000148730.500000000015000−0.3750000000151270.250000000009815−0.125000000020944

(1)
> 

AutoCorrelation⁡1,2,1,2,1,2,1,2,2

1.−0.8750000000090560.750000000020185

(2)
> 

AutoCorrelation⁡1,2,1,2,1,2,1,2,0..2

1.−0.8750000000090560.750000000020185

(3)
> 

AutoCorrelation⁡1,2,1,2,1,2,1,2,1..2

−0.8750000000090560.750000000020185

(4)
> 

AutoCorrelation⁡1,2,1,2,1,2,1,2,2,scaling=unbiased

1.−1.000000000010351.00000000002691

(5)
> 

AutoCorrelation⁡1,2,1,2,1,2,1,2,2,scaling=biased

0.0624999999981250−0.05468749999892540.0468749999998553

(6)
> 

AutoCorrelation⁡1,2,1,2,1,2,1,2,2,raw

0.499999999985000−0.4374999999914030.374999999998843

(7)
> 

t≔TimeSeriesAnalysis:-TimeSeries⁡1,2,1,2,1,2,1,2,8,7,6,5,4,3,2,1,header=Sales,Profits,enddate=2012-01-01,frequency=monthly

t≔Time seriesSales, Profits8 rows of data:2011-06-01 - 2012-01-01

(8)
> 

AutoCorrelation⁡t..,Sales,2

1.−0.8750000000090560.750000000020185

(9)

Autocorrelation can be used to create correlograms which are useful for detecting periodicity in signals.

> 

R≔seq⁡13⁢evalf⁡sin⁡17.2⁢i⁢cos⁡13.8⁢i+1.17+rand⁡0..1⁡⋅23,i=1..500:

> 

LineChart⁡R,size=0.5,golden

> 

AutoCorrelationPlot⁡R,lags=100

Periodicity in a time series can be observed with Autocorrelation.

> 

with⁡TimeSeriesAnalysis:

> 

Data≔Import⁡datasets/sunspots.csv,base=datadir,output=Matrix

Data≔DateMean Sunspot Number17005.0170111.0170216.0170323.0170436.0170558.0170629.0170720.0170810.0⋮⋮315 × 2 Matrix

(10)
> 

tsData≔TimeSeries⁡Data265..310,2

tsData≔Time seriesdata set46 rows of data:1979 - 2024

(11)
> 

S≔AutoCorrelation⁡tsData

S≔1.0.7838900928748260.351423428724205−0.150321630266540−0.543639946257113−0.719092977250328−0.648508489493646−0.3547893172722980.03885422611323160.444115234353966⋮46 element Vector[column]

(12)
> 

AutoCorrelationPlot⁡GetData⁡tsData

Compatibility

• 

The Statistics[AutoCorrelation] command was introduced in Maple 15.

• 

For more information on Maple 15 changes, see Updates in Maple 15.

• 

The Statistics[AutoCorrelation] command was updated in Maple 2015.

• 

The X parameter was updated in Maple 2015.

See Also

ColumnGraph

Statistics[Correlogram]

Statistics[CrossCorrelation]

TimeSeriesAnalysis