Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone help me write a matlab code that finds probability of full house of a poker hand this is what I have function FullHouse

Can someone help me write a matlab code that finds probability of full house of a poker hand this is what I have

function FullHouse clear all clc % Below is a matrix modeling a Deck of Cards. Deck=['AH';'2H';'3H';'4H';'5H';'6H';'7H';'8H';'9H';'TH';'JH';'KH';'QH';.... 'AS';'2S';'3S';'4S';'5S';'6S';'7S';'8S';'9S';'TS';'JS';'KS';'QS';.... 'AD';'2D';'3D';'4D';'5D';'6D';'7D';'8D';'9D';'TD';'JD';'KD';'QD';.... 'AC';'2C';'3C';'4C';'5C';'6C';'7C';'8C';'9C';'TC';'JC';'KC';'QC']; % Below is an explanation of a program to the user. display(' This program simulates The probability of a Full house poker hand. ') % Prompting the user below trials=input(' Please enter the number of trials you want to run. ') % Below we initialize the counter the number of favorable outcomes. counter = 0; % Outer loop to determine multiple poker hands. for i = 1:trials % Shuffling the deck using the random number generator. index = randperm(52); shuffletheDeck = Deck(index); hand = shuffletheDeck(1:5); cards = sort(hand); if (cards(1) == cards(4)) || (cards(2) == cards(5)) counter = counter + 1; end end % Below we determine the frequency of probabality. p = counter / trials; fprintf(' The probability of a Full House Poker Hand using %d trials is %d .',trials,p);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions