Vous êtes sur la page 1sur 3

STAT 340 Assignment 1 – Spring 2018

Last (Family) Name:

First (Given) Name:

Userid (i.e. rametzge):

UW ID (i.e. 20202020):

Due: May 22 at Noon, ONLINE in Crowdmark.

Marking: Please note that the TAs may not mark all questions in this assignment. The exact questions
that will be marked will not be determined until after the due date.

Group Work: Please note that you are permitted to work with others on this assignment. However, the
work handed in must be your own. To make it clearer who you have worked with and what sources you
have used, acknowledge them in the given question. Failure to acknowledge your people/sources may
result in an academic penalty.

Computer Output: Please include all computer code in your assignment, as well as all relevant output
(some examples where examples would be appropriate). Please do not use any libraries that do not
come with the base system – otherwise the teaching assistants will assign you a zero.

Please note that if you are expected to hand in your code in an online drop box you must ensure it runs.
If you leave “>” in your code it will not run, and you will be awarded a zero mark.

May not be reproduced in any manner without the explicit permission of Riley A. Metzger, UW 2018 Page 1
STAT 340 Assignment 1 – Spring 2018

Question 1: Often in simulation we don’t know the answer to our problem, so what we’ll do first is write
a program that solves the problem. We’ll then solve the question theoretically after we have an idea for
what the answer should be. In each case below, you will write a short program to solve the problem. Do
NOT use the theoretical equations and formulae of STATs – instead solve the problems using brute force.

Part A. The Circle Problem: A robot fires a pistol at a square wall (2m x 2m). A circular target is
precisely in the center and centered on the middle of the square. It has radius 1m. The robot fires each
shot independently of the last and is equally likely to hit any point on the wall. What is the probability
that it hits the circle? Of possible use: runif(1,a,b) generates a point at random and
independently from a to b. The code stub is below.

Circle = function(n)
{ #n is the number of shots fired
return()
}

Part B. The Poker Test with Four Cards: Suppose you have four cards which each take on values 0 to 9
independently and with replacement. What is the probability of each of the following….?
 X cards are the same (i.e. 1 < X < = 4)
 All cards are different (i.e. X = 1)
 2 pairs of cards that are the same, i.e. WWYY
Your output should be a vector consisting of a value for the number of unique (i.e. X = 1), pairs (i.e. X=2),
triples (i.e. X=3), quads (i.e. X=4) and 2 pairs. Your column headings should clearly explain what each
element of your vector represents. Of possible use: rank() and sample(). The code stub is below.

PT4 = function(n)
{ #n is the number of iterations
return()
}

Part C. The School Problem: Charlie can take one of two routes to school. Route A takes her along
Maple Street (M), Chestnut Street (C) and Willow Street (W). Route B takes her along Willow Street,
Oak Street (O) and Erables Street (E). The length of time (𝑇𝑖 ), in minutes it takes to travel along each
1 1 1 1
street is: 𝑇𝑀 ~𝐸𝑋𝑃 (5), 𝑇𝐶 ~𝐺𝑎𝑚𝑚𝑎 (5, 2), 𝑇𝑊 ~𝜒52, 𝑇𝑂 ~𝐸𝑋𝑃 (10), and 𝑇𝐸 ~𝐺𝑎𝑚𝑚𝑎 (2, 3). Charlie
takes Route A on the way to school and Route B on the way home. What is the expected longest and
shortest time she is travelling during a day? The code stub is below.

School = function(n)
{ #n is the number of iterations
return()
}

Question 2. Evaluate the following integrals.


∞ (𝑥−1)2
Part A. 𝜃 = ∫−∞ 𝑥𝑒𝑥𝑝 (− 2
) 𝑑𝑥

May not be reproduced in any manner without the explicit permission of Riley A. Metzger, UW 2018 Page 2
STAT 340 Assignment 1 – Spring 2018

1 3𝑥
Part B. 𝜃 = ∫0 3𝑥 2 +1
𝑑𝑥
4
Part C. 𝜃 = ∫1 𝑥𝑙𝑛𝑥 𝑑𝑥
1 1
Part D. 𝜃 = ∫0 1+𝑥 2
𝑑𝑥

Question 3: Let ~𝑈(0,1), 𝑌 = 1 − 𝑋, 𝑈 = 1 + 𝑒 𝑋 and 𝑉 = 2𝑋 + 𝑒 𝑌 .


Part A. Show that 𝑌~𝑈(0,1).
Part B. As a result of Part A, what can you say about 𝐸(𝑓(𝑋)) and 𝐸(𝑓(𝑌))?
Part C. Determine 𝐸(𝑒 𝑋 ).
Part D. Determine 𝐸(𝑋𝑒 𝑋 ).
Part E. Determine 𝐶𝑜𝑣(𝑈, 𝑉).

Question 4. Let 𝐹(𝑥) be the CDF of X. Let 𝑓(𝑥) be the PDF of X. Then the expectation of X can be
written as 𝐸(𝑋) = ∫∀𝑥 𝑥𝑓(𝑥) 𝑑𝑥 = ∫∀𝑥 1 − 𝐹(𝑥) 𝑑𝑥 . The proof of this requires you to take, gasp, an
ACTSC course. To avoid this please show that this statement is true for 𝑋~𝐸𝑋𝑃(𝜆).

Question 5. A certain lottery pays out $1000 per week for life. In the fine print they allow you to win as
a couple – meaning that they will continue to pay you until the last member of the couple dies. The age
at which a male dies is 𝑀~𝐸𝑋𝑃(1/75) and the age at which a female dies is 𝐹~𝐸𝑋𝑃(1/80).
Part A. How many weeks would a male-female couple, who are born on the same day, expect to be
paid if they won on their 40th birthday?
Part B. Using brute force, and R, answer Part A. Call your output vector out where the ith element is
the time the last member of the couple died, in years.

Question 6. Let 𝑋~𝑁(𝜇, 𝜎 2 ) and 𝑌~𝑁(𝜇, 𝜎 2 ). Let 𝑋 ⊥ 𝑌. Is 𝑋 + 𝑌 = 2𝑋? Explain.

Question 7. Jessie (𝐽), and Xiao (𝑋) are the only people in a single line up for food. The length of time,
1
in minutes, they are in line is given respectively by 𝐽~𝜒52 , and 𝑋~𝐸𝑋𝑃 (4). Each time is independent of
the others.
Part A. How long can their friend, Ryan, expect to wait for the two of them to be served? What is the
variance in this length of time?
𝑠2 −𝑠
Part B. The length of time that Sam (S) and Zihao (Z) are in line has CDFs 𝐹(𝑠) = for 1 < 𝑠 < 2, and
2
𝑧 3 −𝑧
𝐹(𝑧) = for 1 < 𝑧 < 3. If Zihao and Sam both arrive at separate line ups at the same time, how
24
long can Ryan expect to wait for the two of them to finish?

May not be reproduced in any manner without the explicit permission of Riley A. Metzger, UW 2018 Page 3

Vous aimerez peut-être aussi