จะใช้ฟังก์ชัน "ความแปรปรวนร่วม" เพื่อคำนวณความแปรปรวนร่วมอย่างถูกต้องได้อย่างไร?
หมายเหตุ:คำถามต่อไปนี้มาจากคำถามที่ 23 ของการสอบเข้าทางคณิตศาสตร์ระดับบัณฑิตศึกษาภาษาจีนปี 2548 (ชุดแรก):
สมมติ $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
นี้เพื่อแก้ปัญหานี้ได้อย่างไร?
คำตอบ
คุณควรใช้สัญกรณ์ที่แยกตัวแปรสุ่มออกจากการแจกแจง รหัสต่อไปนี้จะทำให้คุณได้รับความแปรปรวนและความสัมพันธ์ร่วมกันที่ต้องการ:
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 *)