Lesson 15: Python Loops for Monte Carlo Simulation
March 7, 2018
Review:
- Importing CSV
- Pandas and DataFrames
- Exam 2 on Wed, Mar 14
Presentation:
- Loops
- for loops
- while loops
- Remember the Selling Price Estimates program? It has a “for” loop.
- Here’s an example of a nested “while” loop: Sample Code
- Monte Carlo Simulation
- Same as “Random Walk”
- Enables “probabilistic” forecasts/estimates/etc
Assignment:
- Complete Intermediate Python for Data Science course on DataCamp
- Complete all chapters before beginning this programming assignment
- Create a Python program on repl.it simulating a simple Dice Game:
- Roll 7, 11 or doubles to win
- Other rolls (not 7, 11 or doubles) result in a loss
- Start with $100
- bet $1 per roll
- win pays $3 (a losing roll means you lose your $1 bet)
- roll 100 times and find ending balance
- simulate 100 outcomes (10,000 total rolls of the dice)
- Report the mean and standard deviation of your final balances
- Produce a histogram illustrating the distribution of results
- Submit your assignment
- Email me a link to your repl.it program
- You’ll be scored on the program content + timeliness
- Speed counts, i.e., no due date, earlier submission = better score
- Submit your own program before helping others