Question
HOW TO DO THIS IN R Assume that you have $20 at the beginning of the game. After each round, your balance will change. Q1.
HOW TO DO THIS IN R
Assume that you have $20 at the beginning of the
game. After each round, your balance will change.
Q1.
Each time, if we get an even number, we will get 2 dollars. If we get an odd number, we will lose
dollars. Add the payoff to our balance.
While your balance is greater than 0,
keep playing the game. When your balance is <=0, stop
playing the game.
hint: use while loop instead of for loop
Q2. Add more codes to finish the following task:
Within each round, print on the screen (the current round number = and the round number)
Within each round, print on the screen whether the dice number is even or odd
Within each round, print on the screen the payoff value
Q3. Add more codes to finish the following task:
Print the total number of rounds you played until you stop.
Calculate the variance of the payoff
hint: create a vector to store the payoff of each round, then calculate the variance of the
vector.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started