Question 1 Your lecturer loves chocolate and has two boxes of chocolates in her office, one in the upper drawer and one in the lower drawer of her desk. Whenever she craves for a chocolate, she selects a drawer at random and takes a chocolate from the box in that drawer. We assume that each of the boxes originally contained 20 chocolates. Suppose your lecturer opens a drawer and discovers for the first time that the box in that drawer is empty. We let X denote the number of chocolates left in the other box. It can be shown that the pmf of X is P(X = x) = 40- x 20 22-40, x = 0, 1, 2,..., 20. (a) Define the pmf of X as a function in R, then plot this pmf over its range. (b) Find the probability P(X≥ 5) using the function you defined in (a). (c) Use the sample(...) function to generate 10000 observations from the pmf of X. Assign the results to a variable. (d) Use the observations generated in (c) to obtain an estimate of P(X ≥ 5), and compare your answer with what you found in (b). My answer: (e) Find the mean of X, E(X), using the function you defined in (a).

A First Course in Probability (10th Edition)
10th Edition
ISBN:9780134753119
Author:Sheldon Ross
Publisher:Sheldon Ross
Chapter1: Combinatorial Analysis
Section: Chapter Questions
Problem 1.1P: a. How many different 7-place license plates are possible if the first 2 places are for letters and...
icon
Related questions
Question

need to do with R studio 

The 1st question please

(f)
Use the observations generated in (c) to obtain an estimate of E(X), and compare your answer with what
you found in (e).
My answer:
(g)
Find E[(X + 1)−²] both using the function you defined in (a) and using the observations generated in (c),
and compare your two answers.
My answer:
Question 2
For this question, we require the MosaicCalc package.
# This code installs the package only if it is not already installed, and loads it.
if (! ("mosaicCalc" %in% installed.packages () [, "Package"])){
install.packages ("mosaicCalc", repos = "https://cran.ms.unimelb.edu.au/")
}
library("mosaic Calc")
Let a continuous random variable X have the pdf
(x+1)(2-x),
f(x)
{}
−1<x<2,
elsewhere.
(a)
Define the pdf of X as a function in R, plot that function over the support of X, and verify that f f(x) dx = 1.
(b)
Plot the cdf of X over its support.
Hint: Use the imported antiD(...) function from the package Mosaic Calc.
(c)
Find the mean and variance of X.
Hint: If you would like the integrate(...) function to return only the numerical approximation of the integral
(without the absolute error), you need to use integrate(...)$value.
(d)
Find P(-2 < X < 1) using the pdf.
(e)
Find P(-2 < X < 1) using the cdf.
Transcribed Image Text:(f) Use the observations generated in (c) to obtain an estimate of E(X), and compare your answer with what you found in (e). My answer: (g) Find E[(X + 1)−²] both using the function you defined in (a) and using the observations generated in (c), and compare your two answers. My answer: Question 2 For this question, we require the MosaicCalc package. # This code installs the package only if it is not already installed, and loads it. if (! ("mosaicCalc" %in% installed.packages () [, "Package"])){ install.packages ("mosaicCalc", repos = "https://cran.ms.unimelb.edu.au/") } library("mosaic Calc") Let a continuous random variable X have the pdf (x+1)(2-x), f(x) {} −1<x<2, elsewhere. (a) Define the pdf of X as a function in R, plot that function over the support of X, and verify that f f(x) dx = 1. (b) Plot the cdf of X over its support. Hint: Use the imported antiD(...) function from the package Mosaic Calc. (c) Find the mean and variance of X. Hint: If you would like the integrate(...) function to return only the numerical approximation of the integral (without the absolute error), you need to use integrate(...)$value. (d) Find P(-2 < X < 1) using the pdf. (e) Find P(-2 < X < 1) using the cdf.
Question 1
Your lecturer loves chocolate and has two boxes of chocolates in her office, one in the upper drawer and one
in the lower drawer of her desk. Whenever she craves for a chocolate, she selects a drawer at random and
takes a chocolate from the box in that drawer. We assume that each of the boxes originally contained 20
chocolates. Suppose your lecturer opens a drawer and discovers for the first time that the box in that drawer
is empty. We let X denote the number of chocolates left in the other box.
It can be shown that the pmf of X is
P(X = x) = (40₂-³) 2²-40, x = 0, 1, 2, ..., 20.
20
(a)
Define the pmf of X as a function in R, then plot this pmf over its range.
(b)
Find the probability P(X ≥ 5) using the function you defined in (a).
(c)
Use the sample(...) function to generate 10000 observations from the pmf of X. Assign the results to a
variable.
(d)
Use the observations generated in (c) to obtain an estimate of P(X ≥ 5), and compare your answer with
what you found in (b).
My answer:
Find the mean of X, E(X), using the function you defined in (a).
1
Transcribed Image Text:Question 1 Your lecturer loves chocolate and has two boxes of chocolates in her office, one in the upper drawer and one in the lower drawer of her desk. Whenever she craves for a chocolate, she selects a drawer at random and takes a chocolate from the box in that drawer. We assume that each of the boxes originally contained 20 chocolates. Suppose your lecturer opens a drawer and discovers for the first time that the box in that drawer is empty. We let X denote the number of chocolates left in the other box. It can be shown that the pmf of X is P(X = x) = (40₂-³) 2²-40, x = 0, 1, 2, ..., 20. 20 (a) Define the pmf of X as a function in R, then plot this pmf over its range. (b) Find the probability P(X ≥ 5) using the function you defined in (a). (c) Use the sample(...) function to generate 10000 observations from the pmf of X. Assign the results to a variable. (d) Use the observations generated in (c) to obtain an estimate of P(X ≥ 5), and compare your answer with what you found in (b). My answer: Find the mean of X, E(X), using the function you defined in (a). 1
Expert Solution
steps

Step by step

Solved in 5 steps with 1 images

Blurred answer
Recommended textbooks for you
A First Course in Probability (10th Edition)
A First Course in Probability (10th Edition)
Probability
ISBN:
9780134753119
Author:
Sheldon Ross
Publisher:
PEARSON
A First Course in Probability
A First Course in Probability
Probability
ISBN:
9780321794772
Author:
Sheldon Ross
Publisher:
PEARSON