Question: MATLAB assignment Problem #1 (Matlab, probability and Poker) The scene from an old cowboy movie, where four aces is beat by a straight flush in

MATLAB assignment

MATLAB assignment Problem #1 (Matlab, probability and Poker) The scene from anold cowboy movie, where four aces is beat by a straight flush

Problem #1 (Matlab, probability and Poker) The scene from an old cowboy movie, where four aces is beat by a straight flush in a game of 5-card stud, almost never happens in real life. First, 5-card stud is almost never played anymore and second, it is extraordinarily unlikely that two such powerful hands would be dealt at the same time - especially with only 5 cards to work with A more typical hand of poker would involve much less dramatic confrontations, such as two pair beating one pair. Also, the most popular game played at both casino and private poker games throughout the world is a game called holdem. The main event at the world series of poker, formally at Binions Horseshoe and now at the Rio in Las Vegas, is no-limit holdem with a first prize up to 12 million dollars (larger than first place money in any tennis or golf championship). In holdem, each player is first dealt two individual cards. Then 5 community cards are dealt face up. The best hand using the two individual cards and 5 community cards wins. The best starting hand in holdem is two aces. Because of the computer and all the simulation software available today, in addition to TV coverage, there is an explosion of information about poker strategies and correct play based on probability. The objective of this assignment is to begin to understand some of the methods that might be required to simulate the play and statistical analysis of poker on the computer. The task of writing a complete computer program to simulate poker (or any other game like chess or backgammon) is complex and beyond the scope of the course. However, we will have the computer help us with a much simpler task - computing the probability that a player will be dealt two aces as starting cards in holdem The specific objectives follow. 1. Derive theoretically the probability that you will be dealt two aces as your starting cards in holdem. 2. Write a function M-file that runs a specified number of hands and returns the percent of hands that a player is dealt two aces. The function definition should be function PerTwoAces = ProbTwoAces (Nhands) Nhands = number of hands or trials. PerTwoAces = percentage of hands consisting of 2 aces This type of analysis applied to engineering problems is called a Monte Carlo Method. 3. Perform the following statistical study. Nhands % TWoAces 102 103 You should write a separate script M-file that calls the function ProbTwoAces' five times to perform this study. Produce tabulated output (use the table() command). How do your results in part (3) compare to the theoretically probability derived in part (1)? Hint: There are 52 cards in a deck, if we represent each unique card as a number (1-52), then the Aces could be represented as cards 1.2.3 and 4. Use the built-in function randperm() which generates an output vector of exclusionary random numbers (no number is selected more than once). This function can be called within a "Hand" loop and, along with a suitable if-statement, used to determine the number of times "Two-Aces are draw. Problem #2 Numerical Estimation of Pi) We all know that pi = 3.14159265..., but how might we approximate pi ourselves? Assume that you have a unit square in quadrant II (spans the x axis from - 1:0, and the y axis from 0:1), and a unit (quarter) circle (which falls within this square). We know that Area Quarter-Circle = 0)*r^2, and in this case we know that r = 1. Therefore, the area of the quarter) circle should be pi/4. Prove that this is the case by creating a Monte-Carlo type simulation using random coordinate points in the range of -1:0 for x and 0:1 for y. Determine the ratio of the number of points that fell within the unit (quarter) circle to the total number of points. Note that the ratio*100 is the percent of the total area that is occupied by the (quarter) circle. Comparing the number points inside the circle to the total yields pi. * Utilize 1000 points in your simulation * 1. Create a function that is structured as follows: function (estimate, error] = EstimatePi(numPoints) which will compute the estimated value of pi, calculate the error between this estimate and the actual value of pi, and plot results a. Plot the points that are outside of the (quarter) circle as blue X's, plot the points on or inside the unit (quarter) circle as red O's b. Include title, labels, and legend where appropriate. This should ALWAYS be the case unless told otherwise 2. Display the estimated value of pi from your simulation, and the corresponding error as a percent (note that the pi command is built into matlab) 3. What happens to the error if you increase the number of points used? What happens when you decrease the number of points used? 4. Please submit your code with the number of simulation points equal to 1000. Too many points make the graphs very cluttered, two few provides no good insight. Your plot will look something like the follow: Random Points in Unit Square and Unit Circle (Quadrant 2) o In Circle x Outside Circle Oo 008 y (unitless) 09 2.00 -1 -0.9 -0.8 -0.7 -0.6 -0.5 -0.4 -0.3 -0.2 -0.1 0 x (unitless) Hints: You might find the following built-in functions useful: viscircles () plots circles, rand() generates random numbers between 0 and 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!