Browsing resource, all submissions are temporary.
a. Suppose I define the following function in R.
pn <- function(z=1.1, 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.1)? (Select all that apply) pn(z=1.1, area="right") pn(1.1,"right") pn(-1.1) pn(z=1.1,"right") pn(1.1, lower.tail=FALSE) pn(1.1) pn() pn(1.1, area="middle")
b. What is the result of running pn(-1.56)? it returns 1-2*pnorm(1.56) it returns an error message it returns 2*pnorm(1.56) it returns pnorm(1.56) it returns pnorm(-1.56)
pn(-1.56)
c. What is the result of running pn(-1.13, "left")? it returns 2*pnorm(-1.13) it returns an error message it returns 1-2*pnorm(-1.13) it returns pnorm(-1.13) it returns pnorm(1.13)
pn(-1.13, "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.61 f(2.7)
What value is returned by 'f'? Give your answer to 3 decimal places.