# topic 11 c # # first load the papfelton() function # # this will actually loaded both papfelton() and # qapfelton() source("../apfelton.R") # Now solve the problems papfelton( 3 ) # solves P(X<3) 1 - papfelton( 3.4 ) # solves P(X>3.4) # or, using the alternative approach papfelton( 3.4, lower.tail=FALSE) # also solves P(X>3.4) papfelton( 1.63 ) - papfelton( -1.45 ) #solves P(-1.452.04) # or, using the alternative approach papfelton(0.54)+papfelton(2.04,lower.tail=FALSE) # # now solve the "backwards" problem if finding a # value, y, such that P(X<=y)=0.35. We use # qapfleton() to do this. qapfelton( 0.35 ) # find y such that P(X>=y) = 0.17. # We could do this as qapfelton( 1-0.17 ) # or we could use the lower.tail=FALSE parameter qapfelton( 0.17, lower.tail=FALSE) # # start using pblumenkopf() source("../blumenkopf.R") # find P( X < -2.4 ) pblumenkopf( -2.4 ) # find P( X > 2.4 ) 1 - pblumenkopf( 2.4 ) # the old, short way pblumenkopf( 2.4, lower.tail=FALSE) # the way that is more clear # find P(-1.335 < X < 0.827 ) pblumenkopf( 0.827 ) - pblumenkopf( -1.335 ) # find P( X <1.2 or X > 2.13 ) pblumenkopf( 1.2 ) + (1 - pblumenkopf(2.13) ) #old pblumenkopf( 1.2 ) + pblumenkopf(2.13, lower.tail=FALSE) #new # Find y such that P(X < y ) = 0.513 qblumenkopf( 0.513 ) # Find y such that P( X > y ) = 0.823 qblumenkopf( 1 - 0.823 ) # old way qblumenkopf( 0.823, lower.tail=FALSE ) # better way # Find y such that P( X < -y or X > y ) = 0.123 qblumenkopf( 0.123/2, lower.tail=FALSE) # Find y such that P( -y < X < y ) = 0.950 qblumenkopf( (1-0.950)/2, lower.tail=FALSE)