{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

chapter2_R_key-1

# chapter2_R_key-1 - #\$%\$'\$/0#\$)\$%\$!0)1!2'3'4/5!6)7!7...

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

" !"#\$%"&’ ) *+,%\$& ’\$- ./0 #\$%& ’& ()\$% %\$& )* +,, -./ 0)1/ 2’3/& ’& -.’4 *’,/5 6)7( 7+4-/ 0)1/ +&1 )\$-7\$- ’& -./ )%1/% 2’3/&5 .10 234564789/: ;8<5=8/: >[email protected] > dbinom(2,4,0.25) [1] 0.2109375 > pbinom(2,4,0.25)-pbinom(1,4,0.25) [1] 0.2109375 > pbinom(2,4,0.25) [1] 0.9492188 > pbinom(1,4,0.25) [1] 0.7382812 > qbinom(0.4,4,0.25) [1] 1 > Y=0:10 > plot(Y,dbinom(Y,4,0.25),type="h", ylab="Prob(Y=y|4,0.25)") > mybinom=rbinom(500, 4, 0.25) > mean(mybinom) [1] 0.992 > var(mybinom) [1] 0.797531 > sd(mybinom) [1] 0.893046 > median(mybinom) [1] 1 > quantile(mybinom,0.75) 75%

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

View Full Document
8 2 > hist(mybinom,breaks=0:4) > sum(mybinom<3)/500 [1] 0.938 > sum(mybinom<=4)/500 [1] 1 .)0 234564789/: +56=/: >[email protected]< 8< & > dnorm(20,40,5) [1] 2.676605e-05 > y=seq(20,60,length=300) > plot(y,dnorm(y, 40,5), main="Normal(40,5)",type="l")
9 > plot(y,pnorm(y,40,5),type="l") > pnorm(20,40,5) [1] 3.167124e-05 > pnorm(20,40,5)+(1-pnorm(45,40,5)) [1] 0.1586869 > qnorm(0.5,40,5) [1] 40 > mynorm=rnorm(500,40,5)

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

View Full Document
: > mean(mynorm) [1] 39.87444 > var(mynorm) [1] 24.15553 > sd(mynorm) [1] 4.914827 > median(mynorm) [1] 39.74468 > quantile(mynorm,0.75) 75% 43.27849 > hist(mynorm) > sum(mynorm<40)/500 [1] 0.524 > hist(mynorm, prob=T, main='histogram of 500 rn') > lines(y,dnorm(y,40,5)) .B0C .D0 /<> .E0 F5A GA?7 3/> 75 ?35H 4I/=J:4? ?8=8:/6 75 735?4 /@5K4C @A7 L56 734 >[email protected]<? 8<>89/74> 8< 734?4 ?49785<?M
; [email protected] <%’-/ = 0)1/ -) 7,)- + >)’44)& 1’4-%’?\$-’)& @’-. ,+A?1+BC5 #\$%& ’& 0)1/ +&1 7,)-5 D,4) 0)A7\$-/ -./ -./)%/-’0+, 7%)?+?’,’-( -.+- -./ >)’44)& %+&1)A 3+%’+?,/ ’4 ?’22/% -.+& 95 > x=seq(0,20,by=1) > plot(x,dpois(x,6),type='h',main='Poisson lambda=6',ylab='p(y)') > 1-ppois(3,6) [1] 0.8487961

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 7

chapter2_R_key-1 - #\$%\$'\$/0#\$)\$%\$!0)1!2'3'4/5!6)7!7...

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

View Full Document
Ask a homework question - tutors are online