Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions

Question

11-1 List the basic factors determining pay rates.

Answered: 1 week ago