CorrelationFunction[data,hspec]
估计数据 data 在滞后 hspec 处的相关函数.
CorrelationFunction[proc,hspec]
表示随机过程 proc 在滞后 hspec 处的相关函数.
CorrelationFunction[proc,s,t]
表示随机过程 proc 在时刻 s 和 t 的相关函数.
CorrelationFunction
CorrelationFunction[data,hspec]
估计数据 data 在滞后 hspec 处的相关函数.
CorrelationFunction[proc,hspec]
表示随机过程 proc 在滞后 hspec 处的相关函数.
CorrelationFunction[proc,s,t]
表示随机过程 proc 在时刻 s 和 t 的相关函数.
更多信息
- CorrelationFunction 也被称为自相关或互相关函数(ACF 或 CCF).
- 可以给予 hspec 以下规范:
-
τ 在时刻或滞后 τ {τmax} 单位间隔从0到τmax {τmin,τmax} 单位间隔从 τmin 到 τmax {τmin,τmax,dτ} 从 τmin 到 τmax,步长为 dτ {{τ1,τ2,…}} 使用显式的 {τ1,τ2,…} - CorrelationFunction[{x1,…,xn},h] 等价于
,其中
=Mean[{x1,…,xn}]. - 当 data 是包含一组路径的 TemporalData 时,输出表示在所有路径上的平均值.
- 过程 proc 的 CorrelationFunction 是 CovarianceFunction c,由标准偏差函数 σ 的外积在时刻 s 和 t 进行正态化:
-
c[s,t]/(σ[s]σ[t]) 对于标量值数据或过程 c[s,t]/(σ[s] ⊗ σ[t]) 对于向量值数据或过程 - 符号 ⊗ 表示 KroneckerProduct.
- CorrelationFunction[proc,h] 仅当 proc 是一个弱平稳过程的时候有定义,且等价于 CorrelationFunction[proc,h,0].
- 过程 proc 可以是诸如 ARMAProcess 或 WienerProcess 的任意随机过程.
范例
打开所有单元 关闭所有单元基本范例 (4)
CorrelationFunction[{2, 3, 4, 3}, 2]data = RandomFunction[ARProcess[{.2, .3, .4}, 1], {1, 10 ^ 4}];ListPlot[CorrelationFunction[data, {20}], Filling -> Axis, PlotRange -> All]CorrelationFunction[BinomialProcess[p], s, t]DiscretePlot3D[Evaluate[% /. {p -> 2 / 3}], {s, 1, 10}, {t, 1, 10}, ExtentSize -> 1 / 2, ColorFunction -> "Rainbow"]CorrelationFunction[WienerProcess[μ, σ], s, t]Plot3D[Evaluate[% /. {μ -> 1, σ -> 2}], {s, 0, 10}, {t, 0, 10}, ColorFunction -> "Rainbow"]范围 (13)
经验估计 (7)
CorrelationFunction[Range[10], 9]CorrelationFunction[Range[10], {9}]CorrelationFunction[Range[10], {1, 9, 2}]ts = TemporalData[TimeSeries, {{{-2.9904395734335427, -1.5547517217370468, -2.007044987914736,
-0.7114933373063236, -1.5920036118254968, 0.23183536513859127, 0.056774681349179124,
0.32394041932443046, 0.10382798659711348, -0.684046765274114, - ... 1687325555,
3.410933732368106, 2.5200924558212163, 2.008558601261935, 0.43151331467691206,
0.6249727955196763}}, {{1, 1000, 1}}, 1, {"Continuous", 1}, {"Discrete", 1}, 1,
{ValueDimensions -> 1, ResamplingMethod -> None}}, False, 10.1];corr = CorrelationFunction[ts, {100}]ListPlot[corr, Filling -> Axis]data = RandomFunction[ARProcess[{.8}, 1], {0, 500}, 10]corr = CorrelationFunction[data, {12}];ListPlot[corr, Filling -> 0]proc = MAProcess[{.4, .3, .5, .6, .3}, 1.];data = RandomFunction[proc, {0, 1000}];ListPlot[TemporalData[CorrelationFunction[#, {10}]& /@ {proc, data}], Filling -> {1 -> {2}}, PlotStyle -> PointSize[Medium]]proc = ARProcess[{{{.3, .1}, {.6, .3}}}, {{1, .3}, {.3, .6}}];
data = RandomFunction[proc, {100}];
cov = CorrelationFunction[data, {-6, 6}];Table[ListPlot[cov["Values"][[All, i, j]], Filling -> 0, PlotLabel -> {i, j}], {i, 1, 2}, {j, 1, 2}]随机过程 (6)
CorrelationFunction[ARProcess[{a}, σ^2], s, t]//PiecewiseExpandDiscretePlot3D[Evaluate[% /. {a -> 2 / 3, σ -> 1}], {s, 0, 10}, {t, 0, 10}, ExtentSize -> 1 / 2, ColorFunction -> "Rainbow"]CorrelationFunction[ARProcess[{a}, σ^2], h]//PiecewiseExpandDiscretePlot[Evaluate[% /. {a -> 2 / 3, σ -> 1}], {h, 0, 10}, ExtentSize -> 1 / 2, ColorFunction -> "Rainbow", AxesLabel -> {h, None}]CorrelationFunction[OrnsteinUhlenbeckProcess[μ, σ, θ], s, t]Plot3D[Evaluate[% /. {μ -> 1, σ -> 2, θ -> 1 / 3}], {s, 0, 10}, {t, 0, 10}, ColorFunction -> "Rainbow"]CorrelationFunction[OrnsteinUhlenbeckProcess[μ, σ, θ], h]Plot[Evaluate[% /. {μ -> 1, σ -> 2, θ -> 1 / 3}], {h, 0, 10}, ColorFunction -> "Rainbow", Filling -> Axis, AxesLabel -> {h, None}]CorrelationFunction[BinomialProcess[p], s, t]DiscretePlot3D[Evaluate[% /. p -> 1 / 3], {s, 1, 10}, {t, 1, 10}, ExtentSize -> 1 / 2, ColorFunction -> "Rainbow"]antidiagonals = CorrelationFunction[BinomialProcess[1 / 3], t, t + h]DiscretePlot[Evaluate@Table[antidiagonals, {t, 1, 4}], {h, 0, 5}, ExtentSize -> 1 / 2, PlotLegends -> (Row[{"t = ", #}]& /@ Range[1, 4]), AxesLabel -> {h, None}]CorrelationFunction[PoissonProcess[μ], s, t]Plot3D[Evaluate[% /. μ -> 3], {s, 0, 10}, {t, 0, 10}, ColorFunction -> "Rainbow"]antidiagonals = CorrelationFunction[PoissonProcess[3], t, t + h]Plot[Evaluate@Table[antidiagonals, {t, 1, 4}], {h, 0, 5}, PlotLegends -> (Row[{"t = ", #}]& /@ Range[1, 4]), AxesLabel -> {h, None}]proc1 = ARProcess[{.8}, 1];
proc2 = MAProcess[{-.4, -.7, .6, -1}, 1];
proc3 = SARMAProcess[{}, {}, {3, {.6}, {.1}}, 1];
proc4 = FARIMAProcess[{}, 1 / 3, {}, 1];DiscretePlot[CorrelationFunction[#, h], {h, 0, 15}, ExtentSize -> 1 / 2, PlotRange -> All, PlotLabel -> Head[#]]& /@ {proc1, proc2, proc3, proc4}向量 ARProcess 的互相关图形:
proc = ARProcess[{{{.3, .1}, {.6, .3}}}, {{1, .3}, {.3, .6}}];
cov = CorrelationFunction[proc, h];Table[DiscretePlot[cov[[i, j]], {h, -6, 6}, ExtentSize -> 1 / 2, PlotLabel -> {i, j}], {i, 1, 2}, {j, 1, 2}]应用 (2)
确定下列数据是用 MAProcess 模拟还是用 ARProcess 模拟效果最好:
ListLinePlot[data = TemporalData[TimeSeries, {{{-1.4735257611469446, -0.9158187257309729, -1.9060205147226934,
-1.6174582169404574, -2.633459084244463, -2.104839842098871, -2.8701276893108894,
-2.4118183939601607, -0.5125633448622677, -1.2356329399850385, 1. ... 26394036266876, -0.16380797769527589, 0.3559909972777121,
1.5343047104249412, 0.10763337590714506}}, {{0, 100, 1}}, 1, {"Continuous", 1},
{"Discrete", 1}, 1, {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, False,
10.1]]candidates = {MAProcess[{.5, .4}, 1], ARProcess[{.5, .4}, 1]};SeedRandom[2];ListLinePlot[RandomFunction[#, {0, 100}]]& /@ candidatesListPlot[CorrelationFunction[data, {10}], Filling -> 0]显然,ARProcess 是一个比 MAProcess 更好的候选模型:
ListPlot[CorrelationFunction[#, {10}], PlotLabel -> Head[#], Filling -> 0]& /@ candidatesdata = RandomFunction[MAProcess[{.6, .4, .5}, .1], {1, 500}];acf[data_, lmax_, clev_ : 0.95] := Show[ListPlot[CorrelationFunction[data, {0, lmax}], Filling -> Axis, PlotRange -> {{0, lmax}, All}, PlotStyle -> PointSize[Medium]],
Graphics[{Dashed, Line[{{0, #}, {lmax, #}}]}]& /@ (Quantile[NormalDistribution[], {(1 - clev/2), 1 - (1 - clev/2)}]/Sqrt[data["PathLengths"][[1]]])]acf[data, 20, .95]acf[TemporalData[RandomVariate[NormalDistribution[], 500], Automatic], 20, .95]属性和关系 (12)
proc = ARMAProcess[1, {5 / 6, -1 / 6}, {2 / 3}, 1];
paths = RandomFunction[proc, {0, n = 10}, 10 ^ 3];CorrelationFunction[paths, {10}]scorr = TimeSeriesMapThread[#2(n + 1) / (n + 1 - #1)&, %]corr = CorrelationFunction[proc, {10}]ListPlot[{scorr, corr}, Filling -> 0]过程的相关函数是 Correlation 矩阵的非对角线项:
𝒫 = WienerProcess[μ, σ];Correlation[𝒫[{s, t}], 1, 2]CorrelationFunction[𝒫, s, t]Simplify[%% - %, 0 < s < t]Simplify[CorrelationFunction[{x, y, z}, 0], {x, y, z}∈Reals]样本相关函数与 CovarianceFunction 相关:
data = Range[10];CorrelationFunction[data, {Length[data] - 1}]CovarianceFunction[data, {Length[data] - 1}] / CovarianceFunction[data, 0]% - %%样本相关函数与 AbsoluteCorrelationFunction 相关:
data = Range[10];
n = Length[data];AbsoluteCorrelationFunction[data - Mean[data], {n - 1}]% / First[%]CorrelationFunction[data, {n - 1}]% - %%使用 Expectation 计算相关:
𝒫 = WienerProcess[μ, σ];sd[s_] := StandardDeviation[𝒫[s]]
m[s_] := Mean[𝒫[s]]Expectation[(x[s] - m[s])(x[t] - m[t]) / (sd[s] sd[t]), x𝒫]CorrelationFunction[𝒫, s, t]Simplify[% - %%, 0 < s < t]CorrelationFunction[PoissonProcess[μ], t, t]//Simplify[#, t > 0]&相关函数
与 CovarianceFunction
有关:
𝒫 = OrnsteinUhlenbeckProcess[μ, σ, θ];
sd[s_] := StandardDeviation[𝒫[s]]CorrelationFunction[𝒫, s, t]CovarianceFunction[𝒫, s, t] / (sd[s] sd[t])% - %%相关函数与 Correlation 有关:
𝒫 = WienerProcess[μ, σ];CorrelationFunction[𝒫, s, t]Correlation[𝒫[{s, t}], 1, 2]Simplify[%% - %, 0 < s < t]相关函数对于 ToInvertibleTimeSeries 是不变的:
TimeSeriesInvertibility[proc = MAProcess[{2, 4}, 1]]iproc = ToInvertibleTimeSeries@procCorrelationFunction[#, s, t]& /@ {proc, iproc}data = RandomFunction[ARIMAProcess[{}, 1, {}, 1], {0, 100}];Mean[data]newdata = Standardize[data, Mean, 1&];ListPlot[CorrelationFunction[#, {20}], Filling -> 0]& /@ {data, newdata}n = 100;
sample = RandomInteger[n, n];ListPlot[sample, Filling -> Axis]corr = CorrelationFunction[sample, {1, n - 1}];
ListLinePlot[corr]Total@corr可能存在的问题 (1)
CorrelationFunction 的输出可能包含 DifferenceRoot:
CorrelationFunction[ARProcess[{a, b}, σ^2], t] //Simplify[#, t > 0]&使用 FunctionExpand 来恢复显式的幂:
%//FunctionExpand文本
Wolfram Research (2012),CorrelationFunction,Wolfram 语言函数,https://reference.wolfram.com/language/ref/CorrelationFunction.html.
CMS
Wolfram 语言. 2012. "CorrelationFunction." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/CorrelationFunction.html.
APA
Wolfram 语言. (2012). CorrelationFunction. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/CorrelationFunction.html 年
BibTeX
@misc{reference.wolfram_2026_correlationfunction, author="Wolfram Research", title="{CorrelationFunction}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/CorrelationFunction.html}", note=[Accessed: 07-October-2026]}
BibLaTeX
@online{reference.wolfram_2026_correlationfunction, organization={Wolfram Research}, title={CorrelationFunction}, year={2012}, url={https://reference.wolfram.com/language/ref/CorrelationFunction.html}, note=[Accessed: 07-October-2026]}