ee150_Lab 2broke_m

ee150_Lab 2broke_m - EE 150 Lab 2 Going Broke 1...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Last Revised: 9/10/2008 1 EE 150 Lab 2 Going Broke 1 Introduction In this exercise you will program a simulation of a simple coin-flipping game to find the average number of flips before one of the players goes broke. The scenario is that of three bored students with a large number of quarters (presumably for the laundry machine). To ease their boredom they agree to play a game where all three flip one of their coins examining the resulting combination of heads and tails. If all three coins match (heads or tails), each player takes their coin back. Otherwise, whoever threw the one coin that does NOT match the two others gets all three coins, and the game repeats. Assuming, all players start with n coins, what is the average number of flips before one player goes broke? 1 2 What you will learn This lab exercise will familiarize you with more programming constructs, primarily conditional/selection mechanisms (i.e. if statements). In addition, you will learn how to use the random number generation capabilities of Matlab to perform a type of Monte Carlo simulation that was discussed in class. 3 Background Information and Notes As a Monte Carlo simulation, we will execute a large number of game simulations to arrive at an average duration for each game. This can be easily accomplished by bracketing a single game simulation within a loop and iterating over that loop for some large number of times (say 100,000). By tracking how many flips occurred over the course of 100,000 game simulations and then dividing by 100,000 we can arrive at the duration (in flips) of an average game. Note: While every game has an integral number of flips, the average may not be an integer. One of the primary reasons that it may be easier to simulate this problem rather
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/12/2009 for the course EE 150 taught by Professor Dr.burke during the Fall '08 term at USC.

Page1 / 4

ee150_Lab 2broke_m - EE 150 Lab 2 Going Broke 1...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online