# STAT 400 - Summer 2021
# Discussion/Lab 02
# Solution
#--------------------------------------------------------------------
# Example 3
# a - Find the probability that Stephane's first win happens when he plays his third game
dgeom(x = 2, prob = 0.6) # note that x here is the number of trials BEFORE the first success
# b - Find the probability that Stepahne's fifth win happens when he plays his eighth game
dnbinom(x = 3, size = 5, prob = 0.6) # note that x = number of trials - number of successes
# c - Find the probability that Stephane wins 7 games, if he plays 10 games
dbinom(x = 7, size = 10, prob = 0.6)
# Example 4
# a - What is probability that David makes his first sale on his third call?
dgeom(x = 2, prob = 0.15)
# b - What is the probability that it takes David at least 10 calls to make his first sale?
1 - pgeom(q = 8, prob = 0.15)
dbinom(x = 0, size = 9, prob = 0.15)
# c - If David makes 20 calls, what is the probability that he makes at least 2 sales?
1 - pbinom(q = 1, size = 20, prob = 0.15)
sum(dbinom(seq(2, 20), size = 20, prob = 0.15))