# solution1 - variance is 1.542219. 3 Problem 3 CDF: If 0 ≤...

This preview shows pages 1–2. Sign up to view the full content.

Homework 1 solution 1 Problem 1 Here we need to generate 1000 samples from N(3,4): X 1 ,X 2 ,...,X 1000 , and then use the sample moment 1 1000 1000 i =1 X 6 i to estimate E ( X 6 ). The variance of 1 1000 1000 i =1 X 6 i is 1 1000 V ar ( X 6 ). Using the sample variance of X 6 to estimate V ar ( X 6 ), we obtain the estimated variance of 1 1000 1000 i =1 X 6 i equal to 1 1000 ˆ V ar ( X 6 ), where ˆ V ar ( X 6 ) = 1 999 1000 i =1 ( X 6 i - 1 1000 1000 i =1 X 6 i ) 2 . R code: x=rnorm(1000,3,2) mean(x^6) #estimate of E(x^6) var(x^6)/1000 #estimate of the variance In my run, the estimate of E ( X 6 )=11366.87, and the estimated variance is 1739083. 2 Problem 2 CDF: F ( x ) = R x 0 4 5 ( x 5 ) 3 e - ( x 5 ) 4 dx = R x 0 4( x 5 ) 3 e - ( x 4 ) 4 d x 5 = R x 5 0 4 t 3 e - t 4 dt = R x 5 0 e - t 4 dt 4 = - R x 5 0 de - t 4 = 1 - e - ( x 5 ) 4 . Inverse CDF: U = 1 - e - ( x 5 ) 4 e - ( x 5 ) 4 = 1 - U ⇒ - ( x 5 ) 4 = log (1 - U ) x 5 = ( - log (1 - U )) 1 4 x = 5( - log (1 - U )) 1 4 . R code: U=runif(1000) x=5*(-log(1-U))^(1/4) 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
mean(x) median(x) var(x) In my run, the sample mean is 4.56938, the sample median is 4.5757, and the sample
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: variance is 1.542219. 3 Problem 3 CDF: If 0 ≤ x ≤ 1, then F ( x ) = R x tdt = x 2 2 . If 1 < x ≤ 2, then F ( x ) = R 1 tdt + R x 1 2-tdt = 1 2-(2-t ) 2 2 | x 1 = 1-( x-2) 2 2 . Inverse CDF: If 0 ≤ u ≤ 1 2 , then u = x 2 2 ⇒ x = ± √ 2 u . Because 0 ≤ x ≤ 1, we have x = √ 2 u . If 1 2 < u ≤ 1, then u = 1-( x-2) 2 2 ⇒ 2 u-2 =-( x-2) 2 ⇒ x = 2 ± √ 2-2 u . Because 1 < x ≤ 2, we have x = 2-√ 2-2 u . Algorithm: Step1: generate random sample u from uniform(0,1). Step2: plug u into the inverse CDF function. R code: u=runif(1000) x=rep(0,1000) x[u<=0.5]=sqrt(2*u[u<=0.5]) x[u>0.5]=2-sqrt(2-2*u[u>0.5]) 2...
View Full Document

## This note was uploaded on 10/24/2010 for the course STAT 428 taught by Professor Chen during the Spring '08 term at University of Illinois, Urbana Champaign.

### Page1 / 2

solution1 - variance is 1.542219. 3 Problem 3 CDF: If 0 ≤...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online