Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

MAS2906

Test 2: January 2023 – Example Questions

This  document  contains  seven  test-style  questions,  each  question  being  presented  in  Numbas-only  submission  style,  and  Canvas submission style.  In your test, you will have a mix of questions from Chapters 3–6 of the course notes, some requiring all answers to be submitted directly within Numbas and some questions requiring more detailed calculations and an upload of calculations and/or code to Canvas.   In your test, you will have questions totalling 50 marks.  All questions will be accessed from within the  Numbas application.  Note that the example questions in this document are indicative of the style of questions you are likely to see, and to give you a feel for how you might gain marks.  It is unlikely that questions in your test will be exactly the same as those presented here, and you should make sure you use all examples provided in the practical worksheets, and in the course notes, in your revision.

1    Test-style question on Transformations

A version of a question to be completed entirely within Numbas [5 marks]

Suppose X ~ N(0, 1) and that Y = X2 .  Which option, A– E, correctly specifies the probability density function (PDF) of Y? Note that you are not required to use RStudio for this question.

A.  fY (y) = e y , for 0 s y < o.

B.  fY (y) = e y2 , for 0 s y < o.

C.  fY (y) = e y , for 0 s y < o.

D.  fY (y) = ey/2, for 0 s y < o.

E.  fY (y) = λe(y ey ), for _o < y < o.

Notes to students

❼ This question would appear within Numbas, to be completed entirely within Numbas by simply selecting the correct option

(A– E)

❼ You would have to work out the PDF for Y by hand, on scrap paper, and then simply select the correct option within Numbas ❼ You would therefore not receive any marks for working, just for the correct answer

❼ There  would  be  lots  of different  versions  of the  question  in  circulation  (e.g.   different  distributions  for  x  and  different

transformations), so it would be unlikely that two students get exactly the same question

A version of this question requiring solutions to be submitted to Canvas [10 marks]

Suppose X  ~  N(0, 1) and that Y = X2 .   Find the probability density function (PDF) of Y . Include your full hand-written/typed solution in your solutions document that you will upload to Canvas. Note that you are not required to use RStudio for this question.

Notes to students

❼ This question would appear in Numbas, but would require you to upload your full solution (hand-written or typed) to Canvas ❼ The question will be marked by hand, and marks will be available for method and correct answer

❼ A photograph of your hand-written solution would be acceptable, provided it is clear and your working legible

2    Test-style question on Bivariate Distributions

A version of a question to be completed entirely within Numbas [15 marks]

Suppose X ~ Exp(2) and that

fY |x(Y lX = x) = {0(e)y/xx, 

In RStudio write a function to generate 500 pairs of realizations of (X, Y).

(a)  Produce a scatterplot of X against Y .  Which plot, from the plots shown below, matches

most closely to the plot you have produced in RStudio?  (10 marks)

(b) What is your sample correlation between X and Y? Enter your answer correct to 4 decimal places.  (5 marks)

Note that you are not required to submit any R code code for this question.

Notes to students

❼ In this question, you would not upload your code anywhere

❼ You would use RStudio to write a function, produce a plot and compute a correlation coefficient

❼ For part (a), you would simply select the scatterplot that most closely resembles the plot you have produced; in part (b), you

would enter your correlation coefficient

❼ There would  be  many versions of this question,  and the  parameters within  (e.g.     =  2  in this question) could  also  be

randomised, so it is very unlikely that two students would get the same question

A version of this question requiring solutions to be submitted in Canvas [20 marks]

Suppose X ~ Exp(2) and that

fY |x(Y lX = x) = {0(e)y/xx, 

In RStudio write a function to generate 500 pairs of realizations of (X, Y). Produce a scatterplot of X against Y , and obtain the sample correlation between X and Y . In your solutions document that you upload to Canvas, include (i) the R code for your main function  (8 marks); (ii) your scatterplot (8 marks); (iii) the correlation coefficient (4 marks).  No other code or solutions are needed.

Notes to students

❼ This question would appear in Numbas, but would require you to upload the code for your main function along with the

scatterplot and your correlation coefficient to Canvas

❼ You should simply copy-and-paste the code from RStudio into MS WORD. Alternatively, a screenshot of your code in RStudio

would suffice.  No R les are needed

❼ The question would be marked by hand, and partial credit might be achieved for an incorrect function

3    Test-style question on Bivariate Distributions

A version of a question to be submitted to Canvas [25 marks]

Suppose

Y(X) ~ N2  ┌╱ 1(4) , 2(8)   5(2) .

The random variable Z is defined by Z = X + 3Y .

(a) What is the distribution of Z?   State this distribution fully,  including the  name of the distribution and the value of any parameter(s) within the distribution.

(b)  Use R to simulate 1,000 pairs of observations on (X, Y). Using this sample:

(i)  Estimate P(Z > 8). How does this compare to the true probability?

(ii)  Estimate the correlation  between X  and Y .   How does this compare to the true correlation?

In the solutions document that you upload to Canvas, you should include your working for part (a) (5 marks); the code you have used to produce your sample in part (b) (8 marks); your estimate of the probability in part (b)(i) (3 marks), with a comment on how it compares to the true value (3 marks); your estimate of the correlation in part (b)(ii) (3 marks), with a comment on how this sample value compares to the true value (3 marks) .

Notes to students

❼ This question would appear in Numbas, but would require you to include all necessary pencil-and-paper working, R code, and

answers from RStudio, in the solutions document you upload to Canvas

❼ The question would be marked by hand, and partial credit might be achieved for incorrect R code or calculations

❼ Within  Numbas the coefficients in Z, and the values in the variance-covariance matrix, could be randomised to ensure all

students get different versions of the question

A version of this question to be submitted entirely within Numbas [15 marks]

Suppose

Y(X) ~ N2  ┌╱ 1(4) , 2(8)   5(2) .

The random variable Z is defined by Z = X + 3Y .

(a)  Use R to simulate 1,000 pairs of observations on (X, Y).  Which plot, from those shown

below, most resembles a plot of your sample for X against that for Y?  (7 marks)

(b)  Use your sample in (a) to to estimate P(Z > 8), and enter this correct to 4 decimal places.

(4 marks)

(c)  Use your sample in part (b) to estimate the correlation between X and Y , and enter this correct to 4 decimal places.  (4 marks)

4    Test-style question on the Inverse CDF Method

A version of a question to be submitted to Canvas [20 marks]

It is suggested that the survival times of patients (X years) receiving a new cancer drug will follow a Weibull distribution with cumulative distribution function (CDF)

Fx (x; λ, κ) = 1 _ e(x/入)K ,    x 2 0,    λ, κ > 0,

where λ is referred to as the scale parameter and κ is the shape parameter.

(a) Write an R function that uses the inverse CDF method to generate a sample of size N from the Weibull distribution.  Your function should have three input variables:  N, lambda and kappa.  Include this function in your solutions document that you will upload to Canvas. (10 marks)

(b)  Past studies from a similar drug indicate that λ = 2 and κ = 1 .5.  Use these values, and

your function in part (a), to simulate 10,000 realisations from X, and plot a histogram of these values.  Colour the histogram orange, and make sure your axes are appropriately labelled. Include this histogram in your solutions document for upload to Canvas.  (6 marks)

(c)  Use your simulations in part (b) to estimate the probability that a patient receiving this drug will survive for at least 5 years.  (4 marks)

A version of this question to be submitted entirely within Numbas [10 marks]

It is suggested that the survival times of patients (X years) receiving a new cancer drug will follow a Weibull distribution with cumulative distribution function (CDF)

Fx (x; λ, κ) = 1 _ e(x/入)K ,    x 2 0,    λ, κ > 0,

where λ is referred to as the scale parameter and κ is the shape parameter.

(a) Write an R function that uses the inverse CDF method to generate a sample of size N from the Weibull distribution.  Your function should have three input variables:  N, lambda and kappa. There is nothing to submit to Numbas for this part of the question.

(b)  Past studies from a similar drug indicate that λ = 2 and κ = 1 .5.  Use these values, and

your function in part (a), to simulate 10,000 realisations from X . Use your simulated values to estimate the probability that a patient receiving this drug will survive for at least 5 years. Enter your answer correct to 4 decimal places.  (10 marks)

5    Test-style question on Transformations

A version of a question to be submitted to Canvas [10 marks]

If X ~ Gamma(α, λ) then it has probability density function

λaxa 1 e一入x

fx (x) =        Γ(α)       ,    x > 0,    α, λ > 0 ,

where Γ(A) = (A _ 1)! for integer-valued A. Also, E(X) = α/λ and Var (X) = α/λ2 .

(a) Suppose X ~ Gamma(4, 1).  Find the probability density function (PDF) for Y = X/5.

Make sure you include all necessary working in your solutions document.  (7 marks)

(b)  Find E[Y].  (3 marks)

A version of this question to be submitted entirely within Numbas [12 marks]

If X ~ Gamma(α, λ) then it has probability density function

λaxa 1 e一入x

fx (x) =        Γ(α)       ,    x > 0,    α, λ > 0 ,

where Γ(A) = (A _ 1)! for integer-valued A. Also, E(X) = α/λ and Var (X) = α/λ2 .

(a) Suppose X ~ Gamma(4, 1).  Find the probability density function (PDF) for Y = X/5,

and evaluate this to four decimal places at the points in the table below (9 marks):

Y

1

1.5

2.5

fY (y)

 

 

 

(b)  Find E[Y], entering your annswer correct to four decimal places.  (3 marks)

6    Test–style question on the Inverse CDF method

A version of a question to be submitted to Canvas [20 marks]

A glaciologist is studying the annual rate of retreat, Y metres, of the Zachariae Isstrom glacier in northern Greenland.  Experience suggests that the Pareto distribution, with probability density

function

fY (y ; α, λ) = ya+1 ,    α, λ > 0,    y > λ,

might be a reasonable model to use for the rate of retreat of the glacier, where α and λ are shape and rate parameters, respectively.

(a)  Data from the Zachariae Isstrom glacier are only available for the years 1991–2022. Write

an R function that simulates a series of N annual glacial retreat values for this glacier using the inverse CDF method.  Include this function in your solutions document.  Also include your workings.

(b) We know from studies of a nearby glacier that α s 1 .5; the minimum annual glacial retreat we might expect at the Zachariae Isstrom glacier is 5.5 metres. Using your function in part (a), produce a boxplot of a sample of N = 106  values.  Make sure you remove the outliers from the plot.

(c)  Using your sample in part (b), find the probability that in 2023 the Zachariae Isstrom glacier will retreat by more than 12 metres.

A version of this question to be submitted entirely within Numbas [12 marks]

A glaciologist is studying the annual rate of retreat, Y metres, of the Zachariae Isstrom glacier in northern Greenland.  Experience suggests that the Pareto distribution, with probability density

function

fY (y ; α, λ) = ya+1 ,    α, λ > 0,    y > λ,

might be a reasonable model to use for the rate of retreat of the glacier, where α and λ are shape and rate parameters, respectively.

(a) Write an R function that uses the inverse CDF method to generate a sample of size N from the Pareto distribution.  Your function should have  three  input variables:  N, alpha and lambda. There is nothing to submit to Numbas for this part of the question.

(b)  Past studies from a similar drug indicate that α = 1 .5 and λ = 5 .5. Use these values, and

your function in part (a), to simulate 106  realisations from Y .  Use your simulated values to estimate the probability that in 2023 the Zachariae Isstrom glacier will retreat by more than 12 metres (give your answer to four decimal places).  (10 marks)

7    Test–style question on simulating random variables

A version of a question to be submitted to Canvas [15 marks]

Suppose we suspect a coin is biased. We assume

P(Head) = p ~ Beta(2, 5),

where R’s built-in command rbeta(N,  a, b) can be used to generate a sample of size N from the Beta distribution with parameters a and b.

(a)  Use R to generate a sample of 10,000 values for p . In your solutions file that you will upload

to Canvas, include:

(i) The code you have used to produce this sample;

(ii) A histogram of your sample, coloured yellow;

(iii) Your sample mean, and sample variance, of p .

(iv)  Is our belief that the coin is biased in favour of heads or tails? Explain your answer.

(b)  Now suppose you wish to perform an experiment in which the coin is flipped 10 times and

the number of heads counted.  Rather than perform this experiment by hand, you will use R to simulate the experiment.

(i) Suppose X:  Number of heads observed, and that Xlp ~ Bin(10, p).  Write a func- tion in R to simulate 106  observations on X .  Include this function in your solutions document that you will upload to Canvas.

(ii)  Using your function in (i), produce a bar plot for X .  Include this in your solutions

document.

(iii)  Using your sample, find P(X > 5), and comment.

A version of this question to be submitted entirely within Numbas [10 marks]

Suppose we suspect a coin is biased. We assume

P(Head) = p ~ Beta(2, 5),

where R’s built-in command rbeta(N,  a, b) can be used to generate a sample of size N from the Beta distribution with parameters a and b.

(a)  Use R to generate a sample of 10,000 values for p . From this sample,

(i) estimate E(p);

(ii) estimate Var (p);

(iii) decide whether you think the coin is biased in favour of heads of tails (choose one).

(b)  Now suppose you wish to perform an experiment in which the coin is ipped  10 times

and the number of heads counted.   Rather than perform this experiment by hand, you will use R to simulate the experiment.  Suppose X:  Number of heads observed, and that Xlp ~ Bin(10, p). Write a function in R to simulate 106  observations on X .

(i)  Produce a barplot of your sample.  Which of the barplots shown below most closely resembles your histogram?

(ii)  Use your sample to nd P(X > 5), to four decimal places.