Winning Prizes with Monte Carlo Method

  • Thread starter Thread starter computerex
  • Start date Start date
  • Tags Tags
    Method Monte carlo
AI Thread Summary
The discussion centers on a programming assignment that requires using the Monte Carlo sampling method to estimate the average number of Boost bottles needed to win a prize, given a one in five chance of winning per bottle cap. The main focus is on understanding how to set up the Monte Carlo simulation for this scenario. Participants emphasize that the simulation involves running multiple trials where a "die" represents the process of purchasing bottles until a prize is won. Each trial records the number of bottles consumed, and the average is calculated from these trials. The Monte Carlo method is compared to a game of battleship, illustrating the concept of random sampling and algorithmic analysis. The key takeaway is to simulate the process of buying Boost bottles repeatedly to derive the average number needed to win a prize.
computerex
Messages
68
Reaction score
0
Hello guys, I need some help on my AP CS class assignment.
The assignment is as follows:

"Write a program that uses the Monte Carlo sampling method to estimate the average number of bottles of Boost someone would have to drink to win a prize. There is a one in five chance that a bottle cap will have a prize.

*Determine how many times a die must be rolled in order to win a prize. (This represents one
trial.)

*Calculate the average number of times a die must be rolled in order to win a prize "

I am OK with the programming aspect of the assignment, I just need to get the concept of how Monte Carlos will be set up in this case. As far as I know, in Monte Carlos you have to approximate a range of values (min, max) for the uncertain parameters, then iteratively run the "simulation" substituting random numbers within the specified range in place of the uncertain parameters. How will the model be represented in this case? Any help is appreciated. :)
 
Technology news on Phys.org
If you keep providing hints, maybe I could help you.


The Monte Carlo method can be illustrated as a game of battleship. First a player makes some random shots. Next the player applies algorithms (i.e. a battleship is four dots in the vertical or horizontal direction). Finally based on the outcome of the random sampling and the algorithm the player can determine the likely locations of the other player's ships.

http://en.wikipedia.org/wiki/Monte_Carlo_method
 
In the battleship game reference I posted, there would be two arrays, one for each player.

Code:
double rgPlayerValuesA[nRows][nCols] = { 0.0 };
double rgPlayerValuesB[nRows][nCols] = { 0.0 };
 
Simulate process of buying Boost till you win the prize - that will give you a number of bottles in one trial. Repeat and claculate average. Nothing more fancy.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top