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).

Linear Algebra: A Modern Introduction
4th Edition
ISBN:9781285463247
Author:David Poole
Publisher:David Poole
Chapter2: Systems Of Linear Equations
Section2.4: Applications
Problem 28EQ
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
Linear Algebra: A Modern Introduction
Linear Algebra: A Modern Introduction
Algebra
ISBN:
9781285463247
Author:
David Poole
Publisher:
Cengage Learning
Algebra: Structure And Method, Book 1
Algebra: Structure And Method, Book 1
Algebra
ISBN:
9780395977224
Author:
Richard G. Brown, Mary P. Dolciani, Robert H. Sorgenfrey, William L. Cole
Publisher:
McDougal Littell
Algebra & Trigonometry with Analytic Geometry
Algebra & Trigonometry with Analytic Geometry
Algebra
ISBN:
9781133382119
Author:
Swokowski
Publisher:
Cengage
College Algebra
College Algebra
Algebra
ISBN:
9781337282291
Author:
Ron Larson
Publisher:
Cengage Learning
Elements Of Modern Algebra
Elements Of Modern Algebra
Algebra
ISBN:
9781285463230
Author:
Gilbert, Linda, Jimmie
Publisher:
Cengage Learning,