関数 `Covariance`を使用して共分散を正しく計算するにはどうすればよいですか?
Aug 18 2020
注:以下の質問は、2005年の中国の大学院数学入試(最初のセット)の23番目の質問からのものです。
仮定します $X_{1}, X_{2}, \cdots, X_{n}(n>2)$ 母集団からの単純なランダムサンプルです $\mathrm{N}(0,1)$、および $\bar{X}$ サンプル平均です($\bar{X}=\frac{X_1+X_2+\cdots+X_n}{n}$)、 $Y_{i}=X_{i}-\bar{X}$、 $i=1,2, \cdots, n $。
次に、次の問題を解決する必要があります。
(1)分散 $D Y_{i}$ の $Y_{i}$、$i=1,2, \cdots, n $。
(2)共分散 $\operatorname{Cov}\left(Y_{1}, Y_{n}\right)$ の $Y_{1}$ そして $Y_{n}$。
私はn = 10
この問題を解決するために特別な場合として使用します:
Y1 = TransformedDistribution[x[1] - Sum[x[i], {i, 1, 10}]/10,
Table[x[i] \[Distributed] NormalDistribution[], {i, 1, 10}]]
Variance[Y1]
Y10 = TransformedDistribution[x[10] - Sum[x[i], {i, 1, 10}]/10,
Table[x[i] \[Distributed] NormalDistribution[], {i, 1, 10}]]
Variance[Y10]
Covariance[Y1, Y10]
Correlation[Y1, Y10]
しかし、上記のコードは、の共分散を得ることができないY1
とY10
、正しく(参考答えがあります$-\frac{1}{10}$)。Covariance
この関数を使用してこの問題を解決するにはどうすればよいですか?
回答
3 JimB Aug 18 2020 at 11:06
確率変数をそれらの分布から分離する表記法を使用する必要があります。次のコードは、必要な分散と共分散を取得するはずです。
n = 10;
distY1Yn = TransformedDistribution[{x[1] - Sum[x[i], {i, 1, n}]/n, x[n] - Sum[x[i], {i, 1, n}]/n},
Table[x[i] \[Distributed] NormalDistribution[], {i, 1, n}]];
Covariance[distY1Yn]
(* {{9/10, -(1/10)}, {-(1/10), 9/10}} *)
Correlation[distY1Yn]
(* {{1, -(1/9)}, {-(1/9), 1}} *)
distY1 = TransformedDistribution[x[1] - Sum[x[i], {i, 1, n}]/n,
Table[x[i] \[Distributed] NormalDistribution[], {i, 1, n}]];
Variance[distY1]
(* 9/10 *)
distYn = TransformedDistribution[x[n] - Sum[x[i], {i, 1, n}]/n,
Table[x[i] \[Distributed] NormalDistribution[], {i, 1, n}]];
Variance[distYn]
(* 9/10 *)