You are on page 1of 6

Quiz

May 12, 2016


0.1

Quiz

Suppose a sample of size 3 is taken from a uniform distribution over the interval [0 , ], for the purpose of
testing

H0 : = 1
versus

(1)

H1 : < 1

(2)

The null hypothesis will be rejected if


y1 + y2 + y3 < 0.6
(a) Calculate the probability of committing type I error.
(b) Calculate the probability of committing type II error when = 0.5.
In [16]: n<-10^5
theta<-1
y1<-runif(n,min=0,max=theta)
y2<-runif(n,min=0,max=theta)
y3<-runif(n,min=0,max=theta)
y<-y1+y2+0*y3
hist(y,breaks=80,prob=T)
z1<-seq(0,theta,0.01)
z2<-seq(theta,2*theta,0.01)
lines(z1,z1/theta^2,lty=2,col="red",xlim=c(0,theta))
lines(z2,2/theta-z2/theta^2,lty=2,col="red",xlim=c(0,theta))

In [59]: y<-y1+y2+y3
hist(y,breaks=80,prob=T)
z1<-seq(0,theta,0.01)
z2<-seq(theta,2*theta,0.01)
z3<-seq(2*theta,3*theta,0.01)
lines(z1,z1^2/(2*theta^3),type="l",lty=1,col="red",xlim=c(0,theta))
lines(z2,(-2*z2^2+6*theta*z2-3*theta^2)/(2*theta^3),type="l",lty=1,col="blue",xlim=c(theta,2*th
lines(z3,(3*theta-z3)^2/(2*theta^3),type="l",lty=1,col="red",xlim=c(2*theta,3*theta))

The pdf of W = Y1 + Y2 + Y3 is given by

w2

23

w2 + 6w 32
fW (w; ) =
23 2

(w

3)

0w<
w < 2
2 w 3
otherwise

We need to integrate the pdf from 0 to 0.53. In this region the pdf is given by
Z
=
0

0.6

w2
dw = 0.036
2

(3)

w2
given = 1.
23
(4)

The probability of committing type II error is given by


Z 1.5
=
fW (w; 0.5) dw = 0.716
0.6

In [3]: library(png)
img <- readPNG(3-random.png)
grid::grid.raster(img)

Approximate the pdf with a Normal Distribution W N (, 2 ).


We know that

E(Yi ) =
2
and
2
E(Yi2 ) =
3

So, we have
2
12

Var(Yi ) =
The expected value of Z is given by

3
X

i=1

(5)
(6)

and The variance is

Var(W )

3
X
2
12
i=1

(7)

2
4

(8)

We can compute as follows.

y w
w
0.6 1.5
=
= 1.8
0.5
= 0.0359
=

In [13]: pnorm(0.6,3/2,1/2)
Out[13]:
0.0359303191129258
If = 0.5 then we have W N (3/4, 1/16)

=
=

y w
w
0.6 0.75
= 0.6
0.25
1 0.276 = 0.7257

In [1]: 1-pnorm(0.6,3/4,1/4)
Out[1]:
0.725746882249926
In [4]: img1 <- readPNG(31-random.png)
grid::grid.raster(img1)

(9)
(10)
(11)

In [ ]:

You might also like