You are on page 1of 8

Bomewoik 1

Nanni Chen
Su414SSu9

1.
(a) C0BE:
1-pnoim(u.62, mean = u.S, su =u.uS)
The piobability that a line wiuth is gieatei than u.62 miciometei is u.uu8197SS6.

(b)C0BE:
pnoim(u.6S, mean=u.S, su=u.uS)-pnoim(u.47, mean=u.S, su=u.uS)
The piobability that a line wiuth is between u.47 anu u.6S is u.721u8S7.

(c)C0BE:
qnoim(u.9, u.S, su=u.uS)
The line wiuth of 9u% of samples is below u.S64u776 miciometei.

2.
a.C0BE:
> pioblem2 <- function(x,y){ietuin(x*exp(-x*y))}
> y=seq(1,1u,u.1)
> sample1= pioblem2(1,y)
> sample2= pioblem2(2,y)
> sample4= pioblem2(4,y)
> sample6= pioblem2(6,y)
> sample8= pioblem2(8,y)
> sample1u= pioblem2(1u,y)
> plot(seq(1,1u,u.1),sample1, type="l", col ="ieu")
> lines(sample2, col = "gieen")
> lines(sample4, col = "yellow")
> lines(sample6, col = "black")
> lines(sample8, col = "blue")
>title("piobability of Y",xlab="values foi Y", ylab = "Piobability")


fY|x(y)|x=1 is the ieu line. fY|x(y)|x=2 is the gieen line. fY|x(y)|x=4 is the yellow line.
fY|x(y)|x=6 is the black line. fY|x(y)|x=8 is the blue line.

b.P(Y<2|X=2)= !!!!!!!
!
!
!"= !!
!!!
!"
!
!
=1-e
-4
=u.9817
c.E(Y|X=2)= !!!!!!!!!! ! !! ! !"! ! !!"
!!!
!" !
!!
!
!!
!
u.S
u.E(Y|X=x)= !!!!!!!!!! ! !! ! !"! ! !!"
!!"
!" !
!!
!
!!
!
!
!

e.fXY(x,y)=fY|x(y)*fX(x)=xe
-xy
*(11u)=
!
!"
e
-xy

f.fY(y)= !
!"
!! ! !!
!"
!
=
!!!
!!"!
!!"!!!!
!"!
!



S. C0BE:
>x <- inoim(1uuuuu,mean =u, su=2)
> y <-inoim(1uuuuu,mean=1u, su=S)
a. C0BE:
>mean(2*x+S*y)
E(2X+SY)= 29.98246

b.C0BE:
(su(2*x+S*y))^2
v(2X+SY)= 96.64912

c..C0BE:
pnoim(Su, mean=mean(2*x+S*y), su=su(2*x+S*y))
P(2X+SY<Su)= u.Suu7118

u. C0BE:
pnoim(4u, mean=mean(2*x+S*y), su=su(2*x+S*y))
P(2X+SY<4u)= u.84S8918

4.
a.C0BE:
x=c(67S, S6Su, 17S, 11Su, 29u, 2uuu, 1uu, S7S)
qqnoim(x)
qqline(x)

The ieal value uoesn't match the theoietical line peifectly.
b.C0BE:
newx=log (x)
qqnoim(newx)
qqline(newx)

Aftei the tiansfoimation, the new values fit the theoietical line peifectly. It teims
out the log(y) has a lineai ielationship.


S.
a.C0BE:
summaiy(cuc$height)
summaiy(cuc$age)
table(cuc$exeiany, cuc$genuei)
table(cuc$genhlth)

summaiy foi height:
Nin. 1st Qu. Neuian Siu Qu. Nax.
48.uu 64.uu 67.uu 7u.uu 9S.uu
summaiy foi age:
Nin. 1st Qu. Neuian Siu Qu. Nax.
18.uu S1.uu 4S.uu S7.uu 99.uu

IQR(height)=7u-64=6
IQR(age)=S7-S1=26

ielative fiequency uistiibution foi genuei anu exeiany
m f
u 2149 29S7
1 742u 7494
Theie aie 2149+742u=9S69 males in the sample.
Theie aie 46S7 people in excellent health. The piopoition is 46S72uuuu=2S.28S%

b.C0BE:
mosaicplot(table(cuc$genuei,cuc$smoke1uu),main="genuei anu smoke")

Fiom the plot, the numbei of males having smoking habit is laigei than that of
female. About half of males have smoking habit anu ovei half of females uon't have
smoking habit.

c.C0BE:
weight_female=cuc$weight|cuc$genuei == 'f'j
weight_male=cuc$weight|cuc$genuei == 'm'j
height_female=cuc$height|cuc$genuei == 'f'j
height_male=cuc$height|cuc$genuei == 'm'j
bmi_female<- 7uS*weight_female(height_female)^2
bmi_male<- 7uS*weight_male(height_male)^2
boxplot(bmi_female,bmi_male,names=c("f","m"))

u.C0BE:
hist(height_female) (in Sc, we have uefineu height_female is the subset of female
fiom the whole uata)

Fiom the histogiam, most females' height is between S8 inches to 7u inches.

You might also like