Question

In: Math

Must solve in R code Question 2 The random variable X is a payout table of...

Must solve in R code

Question 2

The random variable X is a payout table of a casino slot machine. The probability mass function is given:

X   -5   0   2   10   20   40   60   1000
Probability   0.65   0.159   0.10   0.05   0.02   0.01   0.01   0.001
Please simulate the results for playing the slot machine 10,000,000 times. Find the mean of these 10,000,000 simulated payout outcomes .

Solutions

Expert Solution

In R, we have first generated the samples from the distribution of X as below:

u~R(0,1)

if (u<..65)

x=-5

if( u>.65 && u<.65+.159)

x=0

if( u>.65+.159 && u<.65+.159+.10)

x=2

and so on.

Finally calculated the sample mean of generated x's and a frequency distribution of the generated x's.

We report the mean as -0.1577593.

R Program

nsim=10000000
x=numeric(nsim)
for(i in 1:nsim)
{
u=runif(1,0,1)
if(u<.65)
x[i]=-5
if(u>.65 && u<.809)
x[i]=0
if(u>.809 && u<.909)
x[i]=2
if(u>.909 && u<.959)
x[i]=10
if(u>.959 && u<.979)
x[i]=20
if(u>.979 && u<.989)
x[i]=40
if(u>.989 && u<.999)
x[i]=60
if(u>.999)
x[i]=1000
}
table(x)
cat("\n","Simulated Mean=",mean(x))

R Output

x
-5 0 2 10 20 40 60 1000
6498761 1589532 1001486 500392 199514 100199 100218 9898


Simulated Mean= -0.1577593

For any query in above, comment.


Related Solutions

R Code 2. Suppose X is a random variable with density f(x; ψ) = 2ψ-2 xI(0...
R Code 2. Suppose X is a random variable with density f(x; ψ) = 2ψ-2 xI(0 ≤ x ≤ ψ), where ψ > 0 is a parameter. (a) Draw a graph of the density when ψ = 3 in R. (b) Write a function called genTri that generates n independent realizations of X. The function should take the arguments n and psi and return a vector of n realizations. Make a histogram of n = 104 realizations and compare the...
Suppose the probability mass function of a random variable X is given by ??x−1?pr(1−p)x−r, ifx=r,r+1,r+2,... f(x)...
Suppose the probability mass function of a random variable X is given by ??x−1?pr(1−p)x−r, ifx=r,r+1,r+2,... f(x) = r−1 0, otherwise If this is the case then we say X is distributed as a Negative Binomial Random Variable with parameters r and p and we write X ∼ NegBin(r, p) (a) If we set r = 1, what distribution do we get? (b) Explain what this random variable models and justify the formula. (Hint: See Section 4.8.2 in Ross.) Math 241...
A random variable Y is a function of random variable X, where y=x^2 and fx(x)=(x+1)/2 from...
A random variable Y is a function of random variable X, where y=x^2 and fx(x)=(x+1)/2 from -1 to 1 and =0 elsewhere. Determine fy(y). In this problem, there are two x values for every y value, which means x=T^-1(y)= +y^0.5 and -y^0.5. Be sure you account for both of these. Ans: fy(y)=0.5y^-0.5
Part 2– R work (must be done in R) Copy and paste your R code and...
Part 2– R work (must be done in R) Copy and paste your R code and output into a word document, along with your written answers to the questions, and upload to Canvas.   Follow these instructions to import the necessary dataset: Before opening the dataset needed for this problem, you’ll need to call the “car”package.  Run the following line of code: > library(car) Now you can import the “Prestige” dataset and use it to answer the question below. Name the data...
Question 1: Given the following probability distribution for a random variable X: x P(X=x) -2 0.30...
Question 1: Given the following probability distribution for a random variable X: x P(X=x) -2 0.30 -1 0.15 0 0.20 1 0.20 2 0.15 a) Explain two reasons why the above distribution is a valid probability distribution. b) Calculate μX and σX. c) Determine the cdf(X), and write it as an additional column in the table. d) Calculate P(−1<X≤3) . e) Draw a histogram that represents the probability distribution of X.
In the accompanying​ table, the random variable x represents the number of televisions in a household...
In the accompanying​ table, the random variable x represents the number of televisions in a household in a certain country. Determine whether or not the table is a probability distribution. If it is a probability​ distribution, find its mean and standard deviation. LOADING... Click the icon to view the data. If the table is a probability​ distribution, what is its​ mean? Select the correct choice below and fill in any answer boxes within your choice. A. Its mean is nothing....
In the accompanying​ table, the random variable x represents the number of televisions in a household...
In the accompanying​ table, the random variable x represents the number of televisions in a household in a certain country. Determine whether or not the table is a probability distribution. If it is a probability​ distribution, find its mean and standard deviation. x | P(x) 0 | 0.05 1 | 0.12 2 | 0.24 3 | 0.31 4 | 0.17 5 | 0.11 If the table is a probability​ distribution, what is its​ mean? Select the correct choice below and...
Determine whether or not the random variable X is a binomial random variable. (a) X is...
Determine whether or not the random variable X is a binomial random variable. (a) X is the number of dots on the top face of a fair die (b) X is the number of hearts in a five card hand drawn (without replacement) from a well shuffled ordinary deck. (c) X is the number of defective parts in a sample of ten randomly selected parts coming from a manufacturing process in which 0.02% of all parts are defective. (d) X...
Random variable X is a continuous uniform (0,4) random variable and Y=X^(1/2). (Note: Y is always...
Random variable X is a continuous uniform (0,4) random variable and Y=X^(1/2). (Note: Y is always the positive root.) What is the P[X>=E[X]] ? What is the E[Y] ? what is the P[Y>=E[Y]]? what is the PFD of fY(y)?
Probability: Y is a normal random variable with ? = 0 and ?^2 = 1. SOLVE...
Probability: Y is a normal random variable with ? = 0 and ?^2 = 1. SOLVE FOR expectation E[Y] and variance Var(Y).
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT