ahiromu
ahiromu
  • Threads: 112
  • Posts: 2107
Joined: Jan 15, 2010
April 4th, 2012 at 4:16:09 PM permalink
After a couple of years I've decided to get reacquainted with MATLAB, this is not school related. So two things:

1. I need some example problems, preferably with a rough answer attached to them. For example: The reason I decided to start back up with this program was because I wanted to know the standard deviation of a thousand hands of blackjack. I don't really care if it can be solved without brute force, it's the kind of thing that will get me to remember the syntax. They do not need to be gambling related, they just need to be interesting and uncomplicated (the question, the actual coding/math can be as complicated as you want it to be).

2. Personally, I learn coding best when I have examples to work from. If you have a code you'd be willing to share with me, just something so that I can look it over and relearn the syntax, I would really appreciate it.

My end goal (that probably won't be reached) is to create a full simulation of casino games. Again, I know things like this exist and it's solely for my own enjoyment and education.

I have a BS in Aerospace Engineering and a minor in Mathematical Physics, I've been out of the game for awhile but you can throw anything at me.


tl;dr

1. Give me example problems to do in MATLAB, they do not need to be gambling related.
Its - Possessive; It's - "It is" / "It has"; There - Location; Their - Possessive; They're - "They are"
pacomartin
pacomartin
  • Threads: 649
  • Posts: 7895
Joined: Jan 14, 2010
April 4th, 2012 at 4:56:29 PM permalink
Problem #1) (easy) With an absorbing Markov transition matrix. It is easy enough to do it with a six sided dice. The probably of covering all six combinations in n rolls of the dice is:

n, probability all 6 sides thrown
6, 1.54% = 5/(18*18)
7, 5.40%
8, 11.40%
9, 18.90%
10, 27.18%
11, 35.62%
12, 43.78%
...
17, 74.46%
...
28, 96.38%

The Markov matrix for the dice is follows. You must raise it to the (n-1) power and look at state 6 (upper right hand corner). It's an absorbing matrix, because once you hit every side of the dice, there are no other states to advance toward.

state 1 2 3 4 5 6
1 1/6 5/6 0 0 0 0
2 0 1/3 2/3 0 0 0
3 0 0 1/2 1/2 0 0
4 0 0 0 2/3 1/3 0
5 0 0 0 0 5/6 1/6
6 0 0 0 0 0 1


Problem #2) Set up your own Markov Transition matrix for pass line craps, and calculate the probability that you can roll a dice 154 times in craps (world record) Answer= 1: 5,590,264,072
ahiromu
ahiromu
  • Threads: 112
  • Posts: 2107
Joined: Jan 15, 2010
April 4th, 2012 at 5:13:55 PM permalink
Perfect, my game is craps. Thank you very much I'll get to it... might be a bit because after I opened up the program it took me a half an hour to remember how to call a function.
Its - Possessive; It's - "It is" / "It has"; There - Location; Their - Possessive; They're - "They are"
pacomartin
pacomartin
  • Threads: 649
  • Posts: 7895
Joined: Jan 14, 2010
April 4th, 2012 at 7:12:38 PM permalink
Just to amplify the meaning of the test problem. From the initial state you would always roll a number on the die. So state 1 would be to have chosen one face of the die.

Now the odds of remaining in state 1, would be 1 out of 6 (that you will roll that number again). The odds of moving on to state 2 where two die faces have been rolled is 5 out of 6 since that is the probability of rolling a different die face.

Once all 6 die faces have been selected, the odds are 100% that you will remain in state 6 . It doesn't matter what you roll since once state 6 has been reached it cannot be undone. That portion of the matrix is referred to as absorbing since the state once achieved, cannot be left.

If I raise the matrix to the fifth power I will get the following matrix.


0.012860% 1.993313% 23.148148% 50.154321% 23.148148% 1.543210%
0.000000% 0.411523% 10.853909% 43.981481% 38.580247% 6.172840%
0.000000% 0.000000% 3.125000% 30.131173% 50.925926% 15.817901%
0.000000% 0.000000% 0.000000% 13.168724% 54.038066% 32.793210%
0.000000% 0.000000% 0.000000% 0.000000% 40.187757% 59.812243%
0.000000% 0.000000% 0.000000% 0.000000% 0.000000% 100.000000%


Now the first row of the matrix gives me the probabilities that starting from state 1, I will advance to state 1,2,3,...6 in 5 rolls of the dice. The answer is 1.543210% that I will have rolled all 6 sides of the die.

But the other answers are there as well. The probability that I rolled the same face all 6 times is 1/6^5 =0.012860% .

The probability of rolling exactly 4 numbers out of the 6 die faces is the most likely (or the mode). That probability is 50.154321% .
The probability of rolling at 4 or more numbers out of the 6 die faces is found by summing the last three numbers
50.154321%+ 23.148148%+ 1.543210% =74.8457% .

The second row will tell you the answer to a less interesting problem, If you are starting from state 2 (two sides have been rolled), then what is the odds that you will be in various states after 5 rolls. Well the odds of being in state 1 are zero, but the odds of being in state 2 are (1/3)^5=0.41152% .

The rest of the matrix can be interpreted similarly.

------------------------
In doing the craps pass line problem you must define similar states. Similarly in craps, the initial roll of the die will merely set up the problem for you. Now you have to define states where you advance to points 4 or 10, 5 or 9, 6 or 8, or you return to pass line roll. For this particular problem it isn't necessary to distinguish between returning to a pass line via a craps or 7,11 . The ultimate question is what is the probability of reaching "n" rolls of the dice before you 7 out.

Like the previous problem, the initial roll is a set up roll, so you need to raise the matrix to the power of 153 to find out the probability of rolling the dice 154 times.

The odds that you will "7-out" on your third roll are 1:9 , so the odds of reaching 3 rolls are 8/9 .
The odds of reaching 5 rolls are 66.74%
The odds of reaching 9 rolls are 37.02%



.
  • Jump to: