Solution: Sample Space=11.10.9=990 outcomes
There are 6.5.4=120 outcomes in which the first ball white and the other two black.
There are 5.6.4=120 outcomes in which the fisrt ball is black the second white and the third black.
There are 5.4.6=120 outcomes in which the first two are black and the third white.
so the result is \(\dfrac{120+120+120}{990}=0.36\)
#we shall solve this problem under the assumption thatall possible outcomes are equally likely.
#by basic rule of counting 11.10.9=sample space
#P(E)=number of outcomes in E/number of outcomes in S
Solution:
Sample space is defined by two mutually-exclusive events- it rains or does not rain. Additionaly a third event occurs when the weatherman predicts rain
Event A1: IT RAINS ON THE WEDDING DAY
Event A2: IT DOES NOT RAIN ON THE WEDDING DAY
Event B:THE WEATHERMAN PREDICTS RAIN
#we apply the Bayes' theorem
#P(A|B) is "Probability of A given B", the probability of A given that B happens
#P(A) is Probability of A
#P(B|A) is "Probability of B given A", the probability of B given that A happens
#P(B) is Probability of B
Instructor’s note: What kind of a weatherman predicts rain 25% of the time for a desert and keeps his job? (Troll Channel)
What is the probabilty that at least three customers among first 10 customers buy red or white?
What is the probabilty that the first red pencil ordered by the fourth costumer or before?
Solutions:
#a) #say probabilty of buying pink pencil is pa
pa=0.3
#probabilty of buying red pencil or white pencil is pb
pb=0.55+0.15
#at least three means 3 to 10 customers ordered red or white pencil with probabilty pb
#Through if we can calculate 0 to 2 customers and remove it from the total probabilty (which is 1) it will be the same.
#p_0 is none of the customers buy white or red.
p_0=pa^10
#p_1 is exactly one of the customer order white or red.
p_1=pb^1*pa^9*choose(10,1)
#p_2 is exactly two of the customers order white or red.
p_2=pb^2*pa^8*choose(10,2)
#1-p_0-p_1-p_2
#b)#probabilty of having the first order a red pencil is 0,55
#probabilty of not having the first order a red pencil but not the second one is 0,45*0,55
#probabilty of not having the first two order a red but not the third one is 0,45*0,45*0,55
#probabilty of not having the first three order a red but not the fourth one is (0,45)^3*0,55
0.55+(0.45)*(0.55)+(0.45)^2*(0.55)+(0.45)^3*(0.55)
## [1] 0.9589938
Kaan is a player in a basketball team. It is 70% that every shot that Kaan makes is the right shot.
What is the probability that Kaan’ll score in three consecutive free shots in the basketball game ?
Solution: He makes 70% of every shot the right shot. So every time he shots it is 0.7.
P(R) = Probability of Right Shots
P(M) = Probability of Misssing Shots
P(R) x P(R) x P(R)= 0.7 x 0.7 x 0.7 = 0.343 = 34.3%
pRight <- 0.7 #Probability of Right Shot
pMiss <- 0.3 #Probability of Missing Shot
pRight*pRight*pRight
## [1] 0.343
If Kaan’s team is 1 point behind and the play will end when after Kaan play two free shots, what is the probability that Kaan’s team will draw or win ?
Solution: Kaan is going to do 2 free shots, to be draw he needs to make right just 1 shot and to win he need to make two right shots.
p(A) = Probability of Win or Draw
p(W) = Probability of Win (He needs to make two shots right)
p(D) = Probability of Draw (He needs to make just one shot right)
P(R) = Probability of Right Shots
P(M) = Probability of Misssing Shots
p(D) = p(R) x p(M) x 2 = 0.7 x 0.3 x 2 = 0.42
p(W) = p(R) x p(R) = 0.7 x 0.7 = 0.49
p(A) = p(W) + p(D) = 0.49 + 0.42 = 0.91
To Draw
pR <- 0.7 #Probability of Right Shot
pM <- 0.3 #Probability of Missing Shot
cS <- 2 #He can make the shot right at first or second shot
cS*pR*pM
## [1] 0.42
To Win
pR <- 0.7 #Probability of Right Shot
pR*pR
## [1] 0.49
To Draw or Win
cD <- 0.42 #Chance to draw
cW <-0.49 #Chance to Win
cD+cW
## [1] 0.91
Instructor’s note: Alternatively calculate the probability of losing (say, \(P(L)\)) and subtract from 1. \(P(L) = P(M)^2 = 0.3^2 = 0.09\). \(P(A) + P(L) = 1\) then \(P(A) = 0.91\).
In a group of 45 people, 20 people love to listen to classical music, 15 loves to listen to pop and 10 love to listen to both pop and classical music. 10 people love neither.
If someone chosen randomly, loves to listen classical music, what is the probability that he/she also loves pop music?
Solution: You are going to divide number of both pop and classical music lovers by the number of classical music listener to find who loves both from between the ones who loves pop music.
n(AnB) = Number people who loves both
n(A) = Number of people who love classical music
p(B|A) = Probability of getting people who also love pop music
p(B|A) = n(AnB)/n(A)
n(AnB) = 10
n(A) = 20
10/20 = 0.5
nA <- 20 # Number of people who loves classical music
nAB <- 10 # Number of people who loves both
nAB/nA
## [1] 0.5
What is the probability of people who love to listen to pop music?
Solution: We are going to divide number of only pop music lovers by the total number of people.
p(B) = probability of people who listen pop music
P(B) = nB/nTotal
n(B)= 15
n(T) = 45
15/45 = 0.3333333
nB <- 15 # Number of people who loves pop music
nTotal <- 45 # Total number of people
nB/nTotal
## [1] 0.3333333
A package contains 12 resistors, 3 of which are defective. If four are selected, find the probability of getting the following.
All non-defective
Solution: There are 12 (m) resistors and only 3 of them are defective. So the number of non-defective ones is 9 (n). We will start from 9/12 and stop multiplication at 6/9.
P(N) = Probability of getting non defective
p(N1) = Probability of getting non defective at first pick
p(N2) = Probability of getting non defective at second pick
p(N3) = Probability of getting non defective at third pick
p(N4) = Probability of getting non defective at fourth
p(N) = p(N1) x p(N2) x p(N3) x p(N4)
9/12 x 8/11 x 7/10 x 6/9 = 3024/11880 = 0.2545455
n_resistors <- 12 #number of resistors
n_ndr <- 9 #number of non-defective resistors
(n_ndr/n_resistors) * (n_ndr-1)/(n_resistors-1) * (n_ndr-2)/(n_resistors-2) * (n_ndr-3)/(n_resistors-3)
## [1] 0.2545455
One defective at the fourth.
Solution: So we are just going to choose one defective and the rest is going to be non-defective. After we choose our defective resistor, the total number of resistors is going to decrease. However, the number of the non-defective resistor will stay the same. It is going to start decreasing after we took our first defective.
p(OD) = Probability of getting one defective
p(D1) = Probability of getting defective at the first pick
p(N2) = Probability of getting non defective at the second pick
p(N3) = Probability of getting non defective at the third pick
p(N4) = Probability of getting non defective at the fourth
P(OD) = p(D1) x P(N2) x P(N3) x P(N4) x 4
3/12 x 9/11 x 8/10 x 7/9 x 4 = 6048/11880 = 0.5090909
n_resistors <- 12 #number of resistors
n_ndr <- 9 #number of non-defective resistors
n_dr <- 3 #number of defective resistors
nC <- 4 #getting the defective one anytime
(n_dr/n_resistors) * (n_ndr)/(n_resistors-1) * (n_ndr-1)/(n_resistors-2) * (n_ndr-2)/(n_resistors-3) * nC
## [1] 0.5090909
Three defective
Solution: The number of defectives will decrease by 1 every time we multiply. When they finish, we are going to use from non-defective ones because it selected four resistors but only 3 of them are defective.
p(TD) = Probability of getting three defective
p(D1) = Probability of getting defective at first pick
p(D2) = Probability of getting defective at second pick
p(D3) = Probability of getting defective at third pick
p(N4) = Probability of getting non-defective at fourth pick
p(TD) = p(D1) x p(D2) x p(D3) x p(N4) x 4
3/12 x 2/11 x 1/10 x 9/9 x 4 = 216/11880 = 0.01818182
n_resistors <- 12 #number of resistors
n_ndr <- 9 #number of non-defective resistors
n_dr <- 3 #number of defective resistors
nC <- 4 #getting the non-defective one anytime
(n_dr/n_resistors) * (n_dr-1)/(n_resistors-1) * (n_dr-2)/(n_resistors-2) * (n_ndr)/(n_resistors-3) * nC
## [1] 0.01818182
pB1= 0.2 #probability of catching a computer virus
pB2= 0.06 #probability of catching virus that will completely disable its operating system
pB1*pB2 #The answer
## [1] 0.012
Burak Yılmaz in a team of 18 football players, has 60 percent probability to start the match in the first 11 (i.e. main team) in the first half of the game, and with 40 percent probability he starts at the second half. If he starts at the first half, he has a 40 percent chance to score at least one goal durıng the match. If he starts at the second half his probability decreases to 12 percent. What is the probability that Burak Yılmaz scores at least one goal?
pB1=0.6 #probabilty of starting first11
pB2=0.4 #probabilty of starting second half
pG1=0.4 #probabilty of goals when starting first11
pG2=0.12 # probability of goals when starting 2nd half
(pB1*pG1)+(pB2*pG2) #the answer
## [1] 0.288
Valonia chocolate sells three flavors: chocolate, banana, and caramel. 55 percent of the sales are chocolate, while 30% are banana, with the rest caramel flavored. Sales are by the cone or the cup. The percentages of cones sales for chocolate, banana, and caramel, are 75%, 60%, and 40%, respectively. Find the probability that the ice cream was sold in a cup.
pBchocalate=0.55 #probability of selling chocolate
pBbanana = 0.30 #probability of selling banana
pBcaramel = 0.15 #probability of selling caramel
pBconechocolate = 0.75 #selling by cone
pBconebanana = 0.60 #selling by cone
pBconecaramel = 0.40 #selling by cone
1-(pBchocalate*pBconechocolate)+(pBbanana*pBconebanana)+(pBcaramel*pBconecaramel)
## [1] 0.8275
n1=70 #A blood type
n2=75 #0 blood type
n3=60 #A blood type
n4=45 #B blood type
n5=n1+n2+n3+n4
n4/n5
## [1] 0.18
#Bayes Rule
n1=3/4 #Tricky coin/Total coin
n2=1/4 #Normal coin/Total coin
n3=0.55 #Probability of getting head(tricky coin)
n4=0.5 #Probability of getting head(normal coin)
n5=n1*(n3)^4
n6=n2*(n4)^4
#(n5/n6)
n5 + n6
## [1] 0.08425469
n1=80 #Probability of Bonnie gets higher points in English
n2=3/8 #Probability of English quizzes
n3=75 #Probability of Frank gets higher points in Math. So 1-n3 is Bonnie's chances of being better.
n4=5/8 #Probability of Math quizzes
# (n1*n2)/(n1*n2+n3*n4)
(n1*n2)/(n1*n2+(1-n3)*n4)
## [1] -1.846154
A=5
## number of elements of sample space A={(2,6),(3,5),(4,4),(5,3),(6,2)} which denotes sum of two faces equals to 8.
C=1 ## number of the first face equals to 4 in the set A.
t=36 ## all posibilities
(C/t)/(A/t)
## [1] 0.2
170 men want to learn German and 80 men want to learn Russian. 120 women want to learn Russian and 30 women want to learn German.
What is the probability of a randomly chosen person from Russian learners to be a man?
MD=170 ## number of men want to learn German
MR=80 ## number of men want to learn Russian
WD=30 ## number of women want to learn German
WR=120 ## number of women want to learn Russian
t=(MD+MR+WD+WR)
(MR/t)/((MR+WR)/t)
## [1] 0.4
What is the probability of getting small size merchandise randomly?
t=0.3 ##probability of buying t-shirts
p=0.4 ##probability of buying pullovers
j=0.3 ##probability of buying jackets
ts=0.05 ##probability of being small of t-shirts
ps=0.08 ##probability of being small of pullovers
js=0.02 ##probability of being small of jackets
A=((t)*(ts))+((p)*(ps))+((j)*(js))
What is the probability that it came from t-shirts?
(t*(ts))/A
## [1] 0.2830189
n_D1 <- 6 #number of possible outcomes of rolling die_1
n_D2 <- 6 #number of possible outcomes of rolling die_2
n_ss <- prod(n_D1,n_D2)
n_event_A <- 3 #event for two die faces sums to 10
n_event_B <- 6 #event for which the first throw equals 5.
pA = n_event_A/n_ss
pB = n_event_B/n_ss
pAnB <- 1/n_ss #which is {5,5}
solution <- pAnB/pA
print(solution)
## [1] 0.3333333
\[P(B|A) = \dfrac{P(A \cap B)}{P(A)}\]
Solution: Let A, B be the events that subsystems work. A1, A2, B1, B2 are the component of the event.
\[P(SystemWorks) = P(A)+P(B)-P(A)P(B)\] \[P(A) = P(A1)+P(A2)-P(A1)P(A2)\] \[P(B) = P(B1)P(B2)\]
pA1 = 0.9
pA2 = 0.9
pB1 = 0.9
pB2 = 0.9
pA = 0.9 + 0.9 - (0.9*0.9)
pB = 0.9*0.9
answer <- (0.9+0.9) - (0.9*0.9) + (0.9*0.9) - (pA*pB)
print(answer)
## [1] 0.9981
pA is having cancer and pB is a positive test result.
pA = 0.01 #probability of having cancer
pAn = 0.99 #probability of not having cancer
pBgA = 0.9
pBgAn = 0.08
answer <- (pBgA*pA)/((pBgA*pA)+(pBgAn*pAn))
print(answer)
## [1] 0.1020408
\[P(A|B) = \dfrac{P(B|A)P(A)}{P(B|A)P(A)+P(B|A')P(A')}\]
Solution: a. (# of combinations including cards which are only from red) / (# of total combinations) = (7,5)/(14,5)
b. ((7,2) * (7,3) + (7,3) * (7,2))/(14,5)
What is the probability of getting the sum equal to (7)
Solution: a- It is only 0. b- P(sum=7) = p (6,1) + p (5,2) + p (4,3) + p (3,4) + p (2,5) + p (1,6) = 6/36 = 1/6
Two teams Brazil and Italy play football every week, somedays in Brazil and somedays in Italy. Brazil won 65% at their court and Italy could win 45% of the time at their court. They played in Brazil 6 out of 10 Times Randomly. Suppose Italy won Yesterday, what is the probability that they played in Italy ?
Solution: (0.45 x 4/10 ) / ((0.65x6/10 ) + ( 0.45 x 4/10 )) = 0.68
#P(A) = the probability of Brazil winning the game.
#P(A| Brazilian court) = 0.65
#P(A| Italian court ) = 0.25