Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Compute Probability of Ace of Diamonds in a Poker Hand
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))
}
@rayfix

This comment has been minimized.

Copy link
Owner Author

rayfix commented Jun 22, 2014

This example uses my simple RAFIntMath framework. https://github.com/rayfix/RAFIntMath

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.