- Details
- Parent Category: Programming Assignments' Solutions

# We Helped With This R Programming Assignment: Have A Similar One?

Category | Programming |
---|---|

Subject | R | R Studio |

Difficulty | Graduate |

Status | Solved |

More Info | Statistics Assignment |

Let us worry about your assignment instead!

- Details
- Parent Category: Programming Assignments' Solutions

SOLVED

Category | Programming |
---|---|

Subject | R | R Studio |

Difficulty | Graduate |

Status | Solved |

More Info | Statistics Assignment |

Must use Rstudio to make functions for the answers described: stated in question. Does not have to be in extreme R language as I am a beginner.

2. We next examine yet another game of chance - a card game. In a standard deck of playing cards, there
are 52 cards, which can be broken down into 4 "suits" (hearts, diamonds, clubs, and spades) of 13 cards.
Within each suit are cards numbered 2, 3, 4, 5, 6, 7, 8, 9, and 10, plus 4 extras: a jack, a queen, a king,
and an ace. The game involves randomly drawing a card from the deck. If the card you draw is numbered 2
through 5, you win $1. If you draw a 6 through 10, you win $2. If you draw a jack, you lose (i.e., you win
$0). If you draw a queen or king, you win $5. If you draw an ace, you win $20.
a. (10 points) What is the maximum you are willing to pay for a chance to play? That is, what is the
expected value of the game?
zero skew?
b. (20 points) Do you the payouts of this game to have a positive, negative,
Write a sentence explaining your expectation. Use the expectation operators from class to compute
the skewness statistic for this game. Does the sign of the skewness statistic confirm your
expectation (i.e., += positive skew; -= negative skew)?
c. (20 points) Use R to simulate this game. That is, you specify the number of times you want to play,
and it generates the results of playing that number of times. Use the function to calculate the
average gain per trial (i.e., the expected value) and skewness of the outcomes. Play the game
100,000 times. Does the expected value match what you calculated in (a)? Does the sign of the
skewness match your expectation from (b)? Write a sentence or two discussing these results.
2

Distributed: 27 Sept 2018
Due: 4 Oct 2018, 1:00pm, in hard copy
Please read each question carefully and be sure to provide answers for all requested components. Your
answers to these questions should be typed using Word or another comparable program. For questions that
require use of R, please include your syntax and output in your response. For all calculations, please provide
full detail of how you arrive at your response, including your use of Excel or other computational resources. In
your verbal answers to the questions, please be as specific as you can. Remember that in statistics, precise
language is very important for effective communication.
This exam is open-book and open-notes. You may use your textbook, lecture notes, homework answer keys,
etc. to address the questions on the exam. Please do not discuss any aspect of the exam with the other
students in the class or anyone else. If you get stuck on a question (especially how to implement something in
R), please email me for clarification.
1. In this first question, we explore the utility of Bayes' theorem by examining the effectiveness of a recent
egg recall. Over a 3-month period in 2010, 550 million eggs were recalled due to possible salmonella
contamination out of a total 17.5 billion eggs produced in the US during that period. A risk assessment
performed by the USDA several years back found that the baseline probability of salmonella contamination
in eggs is about 1/100,000. Let's take this to be the probability of salmonella contamination given that an
egg was not recalled. Finally, it's difficult to find definitive numbers, but let's assume that the probability tha
an egg was contaminated with salmonella given that it was recalled was 1/1000.
a. (20 points) An important question is whether the recall was effective at addressing the problem of
contamination. What is the probability that an egg was recalled given that it was contaminated with
salmonella? Use Bayes' theorem to calculate this value with the help of your favorite calculator.
Does it appear that the recall was effective? Write a few sentences interpreting the probability value
that you calculated.
b. (20 points) Use R to simulate the answer to this question. That is, first generate an event B (an egg
is recalled), for which the unconditional probability of "success" matches above. Then, generate an
event A (an egg is contaminated), for which the probability of "success" varies depending on
whether B was successful or not. Finally, select only trials where A is successful and compute how
frequently B is successful. Run this simulation for 10,000,000 eggs and report the result. Does your
simulated answer match the result of (a)? If the numbers do not match precisely, briefly describe
why they differ. (NB: You may find a different approach that works, but I have found that this is
easiest to accomplish with two separate for loops - one to generate the events, and one to pick out
the ones that match your criteria. Also, it will likely take some time for your program to run with
10,000,000 eggs. You'll probably want to start with a smaller number [like 100,000] until you get
your function up and running.)
c. (10 points) In a random sample of 100 recalled eggs, what is the probability that at least one of the
eggs is contaminated with salmonella? Be sure to show how you compute this value.
1

Is it free to get my assignment evaluated?

Yes. No hidden fees. You pay for the solution only, and all the explanations about how to run it are included in the price. It takes up to 24 hours to get a quote from an expert. In some cases, we can help you faster if an expert is available, but you should always order in advance to avoid the risks. You can place a new order here.

How much does it cost?

The cost depends on many factors: how far away the deadline is, how hard/big the task is, if it is code only or a report, etc. We try to give rough estimates here, but it is just for orientation (in USD):

Regular homework | $20 - $150 |

Advanced homework | $100 - $300 |

Group project or a report | $200 - $500 |

Mid-term or final project | $200 - $800 |

Live exam help | $100 - $300 |

Full thesis | $1000 - $3000 |

How do I pay?

Credit card or PayPal. You don't need to create/have a Payal account in order to pay by a credit card. Paypal offers you "buyer's protection" in case of any issues.

Why do I need to pay in advance?

We have no way to request money after we send you the solution. PayPal works as a middleman, which protects you in case of any disputes, so you should feel safe paying using PayPal.

Do you do essays?

No, unless it is a data analysis essay or report. This is because essays are very personal and it is easy to see when they are written by another person. This is not the case with math and programming.

Why there are no discounts?

It is because we don't want to lie - in such services no discount can be set in advance because we set the price knowing that there is a discount. For example, if we wanted to ask for $100, we could tell that the price is $200 and because you are special, we can do a 50% discount. It is the way all scam websites operate. We set honest prices instead, so there is no need for fake discounts.

Do you do live tutoring?

No, it is simply not how we operate. How often do you meet a great programmer who is also a great speaker? Rarely. It is why we encourage our experts to write down explanations instead of having a live call. It is often enough to get you started - analyzing and running the solutions is a big part of learning.

What happens if I am not satisfied with the solution?

Another expert will review the task, and if your claim is reasonable - we refund the payment and often block the freelancer from our platform. Because we are so harsh with our experts - the ones working with us are very trustworthy to deliver high-quality assignment solutions on time.