# Improved Support of Random Processes in Expectation

Mathematica 10's improved integration of random process and probability and statistics frameworks enables symbolic computation with many slices of a process. In particular, this example investigates two estimators of the absolute autocorrelation function and explores the trade between the estimator's bias and its population variance.

Let denote values of a random process arma at time .

 In[1]:= Xarma\[ScriptCapitalP] = ARMAProcess[{2/5}, {1/5}, 4/3]; \[ScriptCapitalN] = 25;

Consider two-sample estimator of the absolute correlation function sequence and .

 In[2]:= X\!\(\*OverscriptBox[\(\[Gamma]1\), \(^\)]\) = Table[1/\[ScriptCapitalN] \!\( \*UnderoverscriptBox[\(\[Sum]\), \(s = 0\), \(\[ScriptCapitalN] - 1 - h\)]\(x[s]\ x[s + h]\)\), {h, 0, \[ScriptCapitalN] - 1}];
 In[3]:= X\!\(\*OverscriptBox[\(\[Gamma]2\), \(^\)]\) = Table[1/(\[ScriptCapitalN] - h) \!\( \*UnderoverscriptBox[\(\[Sum]\), \(s = 0\), \(\[ScriptCapitalN] - 1 - h\)]\(x[s]\ x[s + h]\)\), {h, 0, \[ScriptCapitalN] - 1}];

Compute population expectation of these estimators for ARMA(1,1) process.

 In[4]:= Xest1mean = Expectation[ \!\(\*OverscriptBox[\(\[Gamma]1\), \(^\)]\), x \[Distributed] arma\[ScriptCapitalP]];
 In[5]:= Xest2mean = Expectation[ \!\(\*OverscriptBox[\(\[Gamma]2\), \(^\)]\), x \[Distributed] arma\[ScriptCapitalP]];

The first estimator, , is biased, while the second, , is unbiased.

 In[6]:= Xest1mean == AbsoluteCorrelationFunction[ arma\[ScriptCapitalP], {\[ScriptCapitalN] - 1}]["Values"]
 Out[6]=
 In[7]:= Xest2mean == AbsoluteCorrelationFunction[ arma\[ScriptCapitalP], {\[ScriptCapitalN] - 1}]["Values"]
 Out[7]=

Compute population variances of these estimators.

 In[8]:= XAbsoluteTiming[est1var = Expectation[( \!\(\*OverscriptBox[\(\[Gamma]1\), \(^\)]\) - est1mean)^2, x \[Distributed] arma\[ScriptCapitalP]];]
 Out[8]=
 In[9]:= XAbsoluteTiming[est2var = Expectation[( \!\(\*OverscriptBox[\(\[Gamma]2\), \(^\)]\) - est2mean)^2, x \[Distributed] arma\[ScriptCapitalP]];]
 Out[9]=

The variance of the unbiased estimator grows for large lags.

 In[10]:= XListPlot[{est1var, est2var}, PlotLegends -> {"Biased", "Unbiased"}]
 Out[10]=

Therefore, AbsoluteCorrelationFunction uses the biased estimator.

 In[11]:= XAbsoluteCorrelationFunction[ Table[x[s], {s, 0, \[ScriptCapitalN] - 1}], {\[ScriptCapitalN] - 1}] == \!\(\*OverscriptBox[\(\[Gamma]1\), \(^\)]\)
 Out[11]=

## Mathematica + Mathematica Online

Questions? Comments? Contact a Wolfram expert »