Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use R simulaiton to help you playa game. You draw two random numbers from two di

ID: 3069247 • Letter: U

Question

Use R simulaiton to help you playa game. You draw two random numbers from two different normal distribution RandomNumber_1 comes from a normal distribution with mean=5 and standard deviation=10. RandomNumber_2 comes from a normal distribution with mean=-20 and standard deviation=100. After generating those random numbers, you will get your monetary prize according to the formula below: Prize = RandomNumber_1 X $1.50 + RandomNumber_2 X $5.00 Now, what would be the probability of having negative prize? (you lose money). Please do 1,000,000 simulations for calculating the probability of losing money. DON'T MULTIPLY 100. The answer should be a number between 0 and 1.

Explanation / Answer

First Create the vectors of random variables containing 1,000,000 rows using the code -

> RandomNumber_1 <- c(rnorm(1000000, mean = 5, sd= 10))
> RandomNumber_2 <- c(rnorm(1000000, mean = -20, sd= 100))

Then define the 'Prize' according to formula given as -

> Prize = c(1.50*RandomNumber_1 + 5*RandomNumber_2)

Now, the variable 'Prize' has 1,000,000 values of profits. And we need to find the probability of finding negative values in this vector. So, we use the following code -

> Probability = sum(Prize < 0)/NROW(Prize)

Then you can get the output as -

> Probability

This gives you the following output-

[1] 0.573068

------------------------------------------------

So, probability of having a negative profit or losing money = 0.573068.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote