Browsing resource, all submissions are temporary.
a. Suppose I define the following function in R.
pn <- function(z=1.35, area="right") { p <- 0 if (area=="right") { # compute the right-tail area p <- pnorm(-z) } else if (area=="left") { # compute the left-tail area p <- pnorm(z) } else if (area=="middle") { # compute the middle area p <- 1-2*pnorm(-abs(z)) } else { # compute the two-tails area p <- 2*pnorm(-abs(z)) } p }
Which of the following commands give the same result as pnorm(-1.35)? (Select all that apply) pn(-1.35) pn(1.35,"right") pn(1.35, area="middle") pn() pn(z=1.35,"right") pn(1.35, lower.tail=FALSE) pn(1.35) pn(z=1.35, area="right")
b. What is the result of running pn(-1.32)? it returns 1-2*pnorm(1.32) it returns pnorm(-1.32) it returns 2*pnorm(1.32) it returns an error message it returns pnorm(1.32)
pn(-1.32)
c. What is the result of running pn(-1.14, "left")? it returns pnorm(1.14) it returns pnorm(-1.14) it returns 1-2*pnorm(-1.14) it returns an error message it returns 2*pnorm(-1.14)
pn(-1.14, "left")
d. A function f is defined as follows.
f
f <- function(z) { pow <- function(x) { x^n } n <- z - floor(z) pow(z+1) }
Suppose I run the following commands
n <- 1.3 f(2.26)
What value is returned by 'f'? Give your answer to 3 decimal places.