Question

Problem 10 Below is a working Matlab program to simulate many games of craps. The program plays 10,000 games, and determines Prob _win. Code this program and play 10,000 games 10 separate times. Make a table of P(win craps) with your ten results. How can you use this table to determine the accuracy of your game simulation % simulate the odds of winning at craps % CES 5010 clear num-10000 %number of simulations x=cei 1( rand (num ,4)*6); win-o try help rand, and help ceil, to see whats happening for i=1 : num summ1 x (i,1)x (i,2) win win+1 else win win+l; end end end Prob winwin/num disp(lProbability of winningnum2str (Prob win)])
0 0
Add a comment Improve this question Transcribed image text
Answer #1

The changes made are highlighted in the code

% simulate the odds of winning at craps CES 5010 4Clear 6um-10000: number of simulations 7- r-10; %number of times to repeat the simulat ion for j 1r repeat the simulation r times x-ceil(rand (nun, 4) 6): win-O; for i= 1:nurn 10 12 13 14 15 16 17 18 19 20 2 1 surom1=x(1,1)HX(1,2); if (sumom 1--7 l surrn1=-11) win-win+1: else surmn2 =x (1,3)+x (i,4); win-win+1: end end end 23 2 4 25end Prob winij)-uin/nun; sthe variable disp ([num2 str(j),) Probability of hoding r results winning-,num2 str (Prob win(j)))) 27 get the 90% confidence (percentile) interval 28-quantile (Prob_win, [O.05,0.95]): 29- avgP roh-mean (Prob win) ; 30disp(l The average winning probability is , num2str (avgProb]]): 31- ldisp ([The 90% percent ile interval for the winning probability is [ ,num2 str(q (1)),, ,num2str(q (2)),] )); 32Get this output

1) Probability of winning-0.3039 2) Probability of winning-0.3016 3) Probability of winning-0.3041 4) Probability of winning-0.309 5) Probability of winning-0.2989 6) Probability of winning-0.3041 7) Probability of winning-0.3029 8) Probability of winning-0.2941 9) Probability of winning-0.3098 10) Probability of winning-0.3031 The average winning probability is 0.30315 The 90% percentile interval for the w inning probability i [0.2941,0.3098] s

We can use the 10 repetitions to get an average estimate of the probability of winning.

We can also get a 90% confidence interval (percentile interval as we will use percentiles, rather than standard error).

90% interval indicates that the significance level of a-1-90/100 0.1

That means a 90% interval would be a/2,1-a/20.1/2,1 -0.1/20.05, 0.95

So 0.05 and 0.95 quantiles would be the 90% confidence interval for the winning probability.

From the output we can see that

  • the average winning probability is 0.30315
  • The 90% percentile interval for the winning probability is [0.2941,0.3098]. That is, we are 90% confident that the true winning probability lies between [0.2941,0.3098].
Add a comment
Know the answer?
Add Answer to:
Problem 10 Below is a working Matlab program to simulate many games of craps. The program...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Problem 9 A single game of craps (a dice game) consists of at most two rolls...

    Problem 9 A single game of craps (a dice game) consists of at most two rolls of a pair of six sided dice. The ways to win are as follows: Win-the first roll of the pair of dice sums to either 7 or 1 (you win, game over, no second roll Win the first roll of the pair of dice does NOT sum to either 7 or 1 but the sum of the second roll is equal to the sum...

  • C++ programming language, starting out with C++. Looping Constructs Write a program to simulate the casino...

    C++ programming language, starting out with C++. Looping Constructs Write a program to simulate the casino game "craps". It should execute N number of games so that you can compute the probability(%) of the "player" winning and the "house" winning. Probability(%) of the "player" winning = PlayerWins / N * 100. Probability(%) of the "house" winning = HouseWins / N * 100. The rules are: Player rolls two dice. When the sum is 7 or 11 on first throw, player...

  • Write a c++ program that simulates a million of games in craps. I am having a...

    Write a c++ program that simulates a million of games in craps. I am having a trouble getting to loop a million of times. I am trying to use a const for a million. This is the code so far. #include <iostream> #include <cstdlib>// contains prototypes for functions srand and rand #include <ctime>// contains prototype for function time #include <iomanip> using namespace std; int rollDice(); // rolls dice, calculates and displays sum void printstats(); int totroll = 0, games, point,...

  • c++ help Write a program that obtains the execution times for the following three code segments...

    c++ help Write a program that obtains the execution times for the following three code segments with the different n. code 1: for(int i = 0; i <= n; i++)   { x = i; } code 2: for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) { x = i + j; } } code 3: for (int i = 0; i <= n; i++) { for (int j =...

  • please use python and provide run result, thank you! click on pic to make it bigger...

    please use python and provide run result, thank you! click on pic to make it bigger For this assignment you will have to investigate the use of the Python random library's random generator function, random.randrange(stop), randrange produces a random integer in the range of 0 to stop-1. You will need to import random at the top of your program. You can find this in the text or using the online resources given in the lectures A Slot Machine Simulation Understand...

  • Java BlackJack Game: Help with 1-4 using the provided code below Source code for Project3.java: import...

    Java BlackJack Game: Help with 1-4 using the provided code below Source code for Project3.java: import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.*; public class Project3 extends JFrame implements ActionListener { private static int winxpos = 0, winypos = 0; // place window here private JButton exitButton, hitButton, stayButton, dealButton, newGameButton; private CardList theDeck = null; private JPanel northPanel; private MyPanel centerPanel; private static JFrame myFrame = null; private CardList playerHand = new CardList(0); private CardList dealerHand = new CardList(0);...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT