University of Toronto Mississauga
STA312 H5S: Computational Statistics – Winter 2020
Instructor: Dr. Luai Al Labadi
Assignment # 1
Due Date: Wed. January 29th, 2020 at beginning of lecture. Late assignments will not be accepted. If you cannot make it to the lecture, you can submit through a colleague.
Electronic submissions will not be accepted.
Solve all questions. However, not all questions on the assignments are marked. The questions to be marked are not announced.
Instructions:
• Start all your R codes with the following information: Question Number, Assignment 1, Your Last Name, First Name, Student Number. For Example,
# Question 3, Assignment 1
# Last Name: ABCD, First Name: XYZW
# St. #: 0123456789
• In this assignment, you should use R only when it is stated in the question “[Computational
Using R]”.
• You may not alter the output (by typing or handwriting anything). Output should be directly copied and pasted to the assignment where needed. If you do not follow these rules, your assignment will not be accepted.
• Format, spelling, and grammar will be marked in addition to the statistical aspects.
• Assignments should presently neatly. Use the following format:
• Theoretical questions can be hand-written or typed using Times New Roman or Arial size 12 font, single spaced, printed double-sided on 8.5×11 inch paper and stapled together in the top left corner, without any other packaging.
• Attach the cover page (provided) at the front of your assignment. (Be sure to include an appropriate title for your assignment and fill in/circle all the information required).
• For marking purposes, include the question numbers/part letters (1a,b,c, etc.) in your answers.
• Do not simply hand in pages of R output without further explanation. Only include the relevant tables or plots that are asked in each question. Make sure to interpret the results in plain English in terms of the problem, quote relevant numbers from the output, and give justifications as a part of your solutions.
• Do not include unnecessary code or output in the body of the assignment. At the end, include an appendix with ALL your R code and output.
• The appendix will be checked to make sure the work was completed individually by the student and that the instructions were followed.
Assignments are individual work. Only general discussion is permitted between students. You must hand in solutions in your own words. Do not let others see your solutions or your selected article. It is plagiarism (a serious academic offence) to submit solutions in other people’s words (including but not limited to other students, the instructor’s, solutions from previous years or courses, websites, etc). You are responsible for knowing and adhering to the University of Toronto’s Code of Behaviour on Academic Matters (see course outline).
STA312- Instructor: Dr. Luai Al Labadi Page 1 of 3
Answer All the following questions.
Follow the form of densities given in the formula sheet.
Question 1 Let FX and fX be, respectively, the cumulative distribution function and the probability density function of X. Let Y = h(X), where h is a strictly monotone function. let GY , gY be a the cumulative distribution function and the probability density function of Y .
(a) [Ch. 2] Assume that h is strictly increasing. Show that GY (y) = FX (h−1(y)). (b) [Ch. 2] Write gY in terms of fX . Assume that h is differentiable.
Question 2 Let X1 ∼ Gamma(α,1) and X2 ∼ Gamma(β,1), where X1 and X2 are independent. Let Y1= X1 and Y2 = X1 + X2.
X1 +X2
(a) [Ch. 2] Show that Y2 ∼ Gamma(α + β, 1). Hint: Use moment generating function.
(b) [Ch. 2] Derive the distribution of 5Y2. Hint: Use moment generating function.
(c) [Ch. 2] Use the Jacobian method to find fY1,Y2 (y1,y2), the joint probability density function of Y1 and Y2. Don’t forget to specify where the density is greater than zero.
(d) [Ch. 2] Use Part (c) to show that Y1 ∼ Beta(α, β).
Question 3 [Ch. 2] Let X ∼ Gamma(n,λ), where n is an integer. Show that X =d Y1 +···+Yn, where
Y1, . . . , Yn are independent Exopnential(λ). Here =d means equals in distribution (i.e. have the same distribution).
Question 4 Assume that U has a uniform distribution on [0, 1].
(a) [Ch. 2] Find the cumulative distribution function of U.
(b) [Ch. 2] Show that U2 has Beta(0.5,1).
(c) [Ch. 3] Use (b) to write an algorithm to generate a sample of size 1000 from Beta(0.5,1). Be as precise as possible.
(d) [Ch. 1; Computational Using R] Now, based in the algorithm in (c), simulate a sample of size 1000 from Beta(0.5,1). For the generated sample, plot the relative frequency histogram and the corresponding density on the same picture. Make appropriate titles. Hint: Consult Ch. 1.
(e) [Ch. 1; Computational Using R] Use the built-in R function ”rbeta” to simulate a sample of size 1000 from Beta(0.5,1). For the generated sample, plot the relative frequency histogram and the corresponding density on the same picture. Make appropriate titles. All plots need to be in one main plot; use “par(mfrow=c(1,2))”. Hint: Consult Ch. 1.
(f) [Ch. 2] Now based on Question 2 and assuming that your computer can generate a sample from Gamma(a, b), a > 0, b > 0, write an algorithm to generate a sample of size 1000 from Beta(0.5, 1). Be as precise as possible.
Question 5 Let X be a continuous random variable with the following probability density function (pdf)
0.5ex fX (x) = 0.5e−x
(a) [Ch. 2] Show that fX (x) is a valid pdf. STA312- Instructor: Dr. Luai Al Labadi
x<0
x ≥ 0 .
Page 2 of 3
(b) [Ch. 2] Find the cumulative distribution function FX (x).
(c) [Ch. 3] Find F−1(x).
X
(d) [Ch. 3] Write an algorithm to generate a sample of size 1000 from the distribution of X using the inverse-transform method. Be as precise as possible.
(e) [Ch. 3; Computational Using R] Now, based in the algorithm in (d), simulate a sample of size 1000 from the distribution of X. For the generated sample, plot the relative frequency histogram and the corresponding density on the same picture. Make appropriate titles. Hint: Consult Ch. 1.
Question 6 (Book Question 3.4) The Rayleigh density is
xe−x2/(2σ2)
fX (x) = σ2
0
x≥0,σ>0 otherwise
.
(a) [Ch. 2] Show that fX (x) is a valid pdf.
(b) [Ch. 2] Show that E(X) = σπ/2.
(c) [Ch. 2] Find the cumulative distribution function FX (x). (d) [Ch. 3] Find F−1(x).
X
(e) [Ch. 3] Develop an algorithm to generate a sample of size 104 from Rayleigh(σ) distribution using the inverse-transform method. Be as precise as possible.
(f) [Ch. 3; Computational Using R] Now, based in the algorithm in (e), simulate a sample of size 104 from Rayleigh(σ) for the values of σ = 1,2,3 and 4. For the generated sample in each case, plot the relative frequency histogram and the corresponding density on the same picture. Make appropriate titles. All plots need to be in one main plot; use “par(mfrow=c(2,2))”. Check that the mean is close to the theoretical mean σπ/2. Hint: Consult Ch. 1.
Good Luck
STA312- Instructor: Dr. Luai Al Labadi Page 3 of 3