Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please i need help for problem 4 and 5. using R programming to answer. because i want to get the right codes for them. 3.

Please i need help for problem 4 and 5.

using R programming to answer.

because i want to get the right codes for them.

image text in transcribed

image text in transcribed

image text in transcribed

3. Consider a random variable X with value given by the following experiment: First, flip a coin, with probability of heads eqal to 2/3 and probability of tails 1/3. Then f heads come up, let X be a random draw from. Ar(1-1, 2): if tails come up, let X be a random draw frorn N( 5.-|/2). The distribution of X is called a mirture distribution. Let Fx and fx be the CDF and pdf for X* Prove that FX-|Fy(x-1,-2) + FN(-5,-1/2) a. c. Plot Fx and fx d. Generate 1,000 random numbers, i.i.d. with the distribution of X. Plot a histogram of these data. 4. Using the same setup as in Question 3, define the following functions in R (keep the code as simple as you can; no need to optimize the code, or to validate the inputs): a. pmix, with one parameter q, providing the values of Fx b. dmix, with one parameter x, providing the values of fx c. rmix, with one parameter n, for generating n random numbers ii.d. with the distribution of X d. qmix with one parameter p, providing the values of FX (the inverse CDF. i.e., the quantile function). Hint: Use the function uniroot. with the function pmix and option extend!nt="yes" Repeat Question 5, but for a general mixture of two normal distributions, with exra parameters: mean1, sd1, mean2, sd2, and mixprob. Call your functions pnormix, dnormmix, qnormmix, and rnormmix. Make sure that qnormmix can accept p as a vector (it is OK to use a for loop to deal with that), and that values of p equal to 0 or 1 produce the appropriate infinities 3. Consider a random variable X with value given by the following experiment: First, flip a coin, with probability of heads eqal to 2/3 and probability of tails 1/3. Then f heads come up, let X be a random draw from. Ar(1-1, 2): if tails come up, let X be a random draw frorn N( 5.-|/2). The distribution of X is called a mirture distribution. Let Fx and fx be the CDF and pdf for X* Prove that FX-|Fy(x-1,-2) + FN(-5,-1/2) a. c. Plot Fx and fx d. Generate 1,000 random numbers, i.i.d. with the distribution of X. Plot a histogram of these data. 4. Using the same setup as in Question 3, define the following functions in R (keep the code as simple as you can; no need to optimize the code, or to validate the inputs): a. pmix, with one parameter q, providing the values of Fx b. dmix, with one parameter x, providing the values of fx c. rmix, with one parameter n, for generating n random numbers ii.d. with the distribution of X d. qmix with one parameter p, providing the values of FX (the inverse CDF. i.e., the quantile function). Hint: Use the function uniroot. with the function pmix and option extend!nt="yes" Repeat Question 5, but for a general mixture of two normal distributions, with exra parameters: mean1, sd1, mean2, sd2, and mixprob. Call your functions pnormix, dnormmix, qnormmix, and rnormmix. Make sure that qnormmix can accept p as a vector (it is OK to use a for loop to deal with that), and that values of p equal to 0 or 1 produce the appropriate infinities

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Logics For Databases And Information Systems

Authors: Jan Chomicki ,Gunter Saake

1st Edition

1461375827, 978-1461375821

More Books

Students also viewed these Databases questions

Question

What is a random sample?

Answered: 1 week ago