Created
June 22, 2014 07:56
-
-
Save rayfix/02ca4d9537af011dd12f to your computer and use it in GitHub Desktop.
Compute Probability of Ace of Diamonds in a Poker Hand
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func testPokerAceOfDiamonds() | |
{ | |
let handsWithAceOfDiamonds = Binomial(n: 51, choose: 4) | |
let allPossibleHands = Binomial(n: 52, choose: 5) | |
let probabilityOfAceOfDiamonds = handsWithAceOfDiamonds / allPossibleHands | |
XCTAssertEqual(probabilityOfAceOfDiamonds, Rational(5,52)) | |
let probabilityOfNoAceOfDiamonds = Rational(1) - probabilityOfAceOfDiamonds | |
XCTAssertEqual(probabilityOfNoAceOfDiamonds, Rational(47,52)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This example uses my simple RAFIntMath framework. https://github.com/rayfix/RAFIntMath