Question: 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.

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. Consider a random variable X with value given by the following

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!