User Tools

Site Tools


expected_value_and_variance_properties

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
expected_value_and_variance_properties [2023/10/04 12:58] – [e.gs in R] hkimscilexpected_value_and_variance_properties [2025/09/06 10:28] (current) – [e.gs in R] hkimscil
Line 33: Line 33:
  
 \begin{align*} \begin{align*}
-Var[aX] & = E[a^2X^2] − (E[aX])^2 \\ +Var[aX] & = E[a^2X^2] − (E[aX])^2 \\ 
- & = a^2 E[X^2] - (a E[X])^2 \\ + & = a^2 E[X^2] - (a E[X])^2 \\ 
- & = a^2 E[X^2] - (a^2 E[X]^2) \\ + & = a^2 E[X^2] - (a^2 E[X]^2) \\ 
- & = a^2 (E[X^2] - (E[X])^2) \\ + & = a^2 (E[X^2] - (E[X])^2) \\ 
- & = a^2 (Var[X]) \label{var.theorem.2} \tag{variance theorem 2} \\+ & = a^2 (Var[X]) \label{var.theorem.2} \tag{variance theorem 2} \\
 \end{align*} \end{align*}
 ====== Theorem 3: Why Var[X+c] = Var[X] ====== ====== Theorem 3: Why Var[X+c] = Var[X] ======
Line 193: Line 193:
 # variance theorem 4-1, 4-2 # variance theorem 4-1, 4-2
 # http://commres.net/wiki/variance_theorem # http://commres.net/wiki/variance_theorem
 +
 # need a function, rnorm2 # need a function, rnorm2
-rnorm2 <- function(n,mean,sd) { mean+sd*scale(rnorm(n)) }+rnorm2 <- function(n,mean,sd) {  
 +    mean+sd*scale(rnorm(n))  
 +}
  
-m <- 0+m <- 50  
 v <- 4 v <- 4
 n <- 100000 n <- 100000
Line 204: Line 207:
 x3 <- rnorm2(n, m, sqrt(v)) x3 <- rnorm2(n, m, sqrt(v))
  
-m.x1 <- round(mean(x1),3) +# Note: x1, x2, x3는 평균과 표준편차를 
-m.x2 <- round(mean(x2),3) +# 같은 값으로 갖는 (공유하는독립적인  
-m.x3 <- round(mean(x3),3+# 집단
-m.x1 +
-m.x2 +
-m.x3+
  
-v.x1 <- var(x1) +y1 <- 3*x1 +5  
-v.x2 <- var(x2+exp.y1 <- mean(y1)  
-v.x3 <- var(x3+exp.3xplus5 <- 3 * mean(x1+ 5 
-v.x1 +exp.y1 
-v.x2 +exp.3xplus5 
-v.x3+ 
 +var(x1)  
 +var((3*x1)+5) 
 +3^2 * var(x1) 
 +var(y1)  # 9 * var(x) 위와 동일
  
 v.12 <- var(x1 + x2) v.12 <- var(x1 + x2)
 v.12 v.12
 +
 ###################################### ######################################
 ## v.12 should be near var(x1)+var(x2) ## v.12 should be near var(x1)+var(x2)
 ###################################### ######################################
-## 정확히 2*v가 아닌 이유는 x1, x2가  +# 정확히 2*v가 아닌 이유는 x1, x2가  
-## 아주 약간은 (random하게) dependent하기 때문  +# 아주 약간은 (random하게) dependent하기 때문  
-##(혹은 상관관계가 있기 때문) +# (혹은 상관관계가 있기 때문, covariance가  
-## theorem 5-1 에서  +있기 때문) 
-## var(x1+x2) = var(x1)+var(x2)+ (2*cov(x1,x2))+# theorem 5-1 에서  
 +# var(x1+x2) = var(x1)+var(x2)+ (2*cov(x1,x2))
  
 cov.x1x2 <- cov(x1,x2) cov.x1x2 <- cov(x1,x2)
Line 245: Line 251:
 v.11 <- var(x1 + x1)  v.11 <- var(x1 + x1) 
 # var(2*x1) = 2^2 var(X1) # var(2*x1) = 2^2 var(X1)
 +2^2*var(x1)
 v.11 v.11
  
 </code> </code>
  
- 
-  
expected_value_and_variance_properties.1696391896.txt.gz · Last modified: 2023/10/04 12:58 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki