In a poker hand, John has a very strong hand and bets 5 dollars. The probability that Mary has a better hand is .04. If Mary had a better hand she would raise with probability .9, but with a poorer hand she would only raise with probability .1. If Mary raises, what is the probability that she has a better hand than John does?
\[P(A|B) = \dfrac{P(B|A)*P(A)}{P(B)}\]
\[P(better \quad hand \quad | \quad raises ) = \dfrac{P(raises \quad | \quad better \quad hand)\quad*\quad P(better \quad hand)}{P(raises)}\]
\[P(better \quad hand \quad | \quad raises ) = \dfrac{P(raises \quad | \quad better \quad hand)}{P(raise \quad given \quad better \quad * \quad better \quad hand) + P(raise \quad given \quad poorer \quad * \quad poorer \quad hand)}\]
\[P(better \quad hand \quad | \quad raises ) = \dfrac{(.9*.04)}{(.9 * .04)+(.1*.96)}\]
mary_better_hand <- .04
raise_given_mary_better_hand <- .9
raise_given_mary_poorer_hand <- .1
num <- (raise_given_mary_better_hand * mary_better_hand)
dem <- (raise_given_mary_better_hand * mary_better_hand)+(raise_given_mary_poorer_hand*(1-mary_better_hand))
paste("P(better hand | raises =)", round(num/dem, 4))
## [1] "P(better hand | raises =) 0.2727"