Lab Assignment 3

advertisement
General Instructions
I
Insert the pdf plots for Exercises 1 and 2 in a word document.
For Exercises 3 and 4, in addition to giving the answers, you
should copy the commands you use and the response R gives
from the R console and paste it in the word document.
I
Upload your Lab Assignment 3 word document on Angel.
M. George Akritas
Lab Assignment 3
Exercise 1
Use commands similar to those given in Lab 3 for plotting the
Binomial pmf and doing a histogram and bar graph of empirical
probabilities to do the following things, all of which pertain to the
hypergeometric distribution with parameters M = 40, N = 100 and
n = 10:
1. Do a basic plot of the pmf with customized labels and
connecting the dots.
2. Do a bar graph of the pmf and add color.
3. Generate 10000 random numbers and store them in the object
x, and do a bar graph of the empirical probabilities.
M. George Akritas
Lab Assignment 3
Exercise 2
Use commands similar to those given in Lab 3 for plotting and
superimposing normal PDFs, as well as for shading areas under the
pdf, to do the following things, all of which pertain to the
exponential distribution with parameters to be specified:
1. Superimpose the PDFs of the exponential distributions with
parameters λ = 0.6 and λ = 0.3 using colors to differentiate
the two curves. Use the curve command and specify from=0,
to=10. (Do first the plot of the pdf with λ = 0.6.)
2. Plot the pdf of the exponential distribution with λ = 0.3 and
shade the area to the left of the 90th percentile.
M. George Akritas
Lab Assignment 3
Exercise 3
This activity uses the integrate function in R, similar to the first
slide of the Integration in R section of Lab 3:
The random variable P, which takes values between 0 and 1, has
pdf fP (p) = .07p −0.93 . (I know we usually do not use P for a
random variable, but see Problem 13, p. 109.)
1. Compute the probability P(P ≤ 0.2) using the commands:
a) f=function(p){.07*p**(-0.93)} (this defines the pdf as the
function f in R), and b) integrate(f,lower=0,upper=.2).
2. Confirm that fP (p) is a proper pdf by computing the area
under the curve from 0 to 1.
M. George Akritas
Lab Assignment 3
Exercise 4
Let X and Y be independent with X be hypergeometric with
M = 6, N = 20 and n = 2, and Y be hypergeometric with M = 8,
N = 20 and n = 3. The pages mentioned below refer the lecture
slide Lessons 12&14 with R.
1. Form the matrix of joint probabilities of X and Y . (See p. 18
for similar commands.)
2. Use the matrix of joint probabilities to find the marginal
PMFs of X and Y , as well as the conditional pmf of Y given
that X = 1. (Similar commands are given in p. 10.)
3. Find the probability P(X + Y ≤ 3). (Similar commands are
given in p. 21.)
4. Find the expected value E (X + Y )2 ). (Similar commands are
given in p. 31)
M. George Akritas
Lab Assignment 3
Download