# Group 8

1. If 3 balls are randomly drawn from a bowl containing 6 white and 5 black balls, what is the probabilty that one of the drawn balls is white and other two black?

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
1. A woman is getting married tomorrow, at an outdoor ceremony in desert. In recent years, it has rained 3 days each year. Unfortunately the weatherman says that tomorrow is going be rainy. When it actually rains, the weatherman correctly forecast rain %75 of the time. When it does not rain, he incorrectly forecasts rain %25 of the time. What is the probabilty that will rain on the day of wedding?

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

• P(A1) = $$\dfrac{3}{365}=0,00821918$$ (it rains 3 days in one year)
• P(B/A1) = 0.75
• P(B/A2) = 0.25
• P(A2) = $$\dfrac{362}{365}=0,99198082$$[it doesnt rain 362 days out of the year]
• P(A1|B) = $$\dfrac{P(A1)P(B|A1)}{P(A1) P(B|A1)+P(A2) P(B|A2)}$$
• P(A1|B) = $$\dfrac{0,008.0.75}{0,008.0,75+0,992.0,1}$$ = $$\dfrac{0,006}{0,254}=0,024$$
#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)

1. A book store has three kinds of pencil; pink, red and white. A customer buys pink pencil with probabilty 0.3, red 0.55 and white 0.15.
1. What is the probabilty that at least three customers among first 10 customers buy red or white?

2. 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

# Group 1

1. Kaan is a player in a basketball team. It is 70% that every shot that Kaan makes is the right shot.

1. 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
2. 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$$.

2. 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.

1. 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
2. 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
3. A package contains 12 resistors, 3 of which are defective. If four are selected, find the probability of getting the following.

1. 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
2. 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
3. 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

# Group 2

1. The director of an insurance company’s computing center estimates that the company’s computer has a 20% chance of catching a computer virus. However, she feels that there is only a 6% chance of the computer’s catching a virus that will completely disable its operating system. If the company’s computer should catch a virus, what is the probability that the operating system will be completely disabled?
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
1. 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
2. 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

# Group 3

1. The blood groups of 250 people is distributed as follows: 75 have type O blood, 60 have AB blood type, 70 have A blood type and 45 have type B blood. If a person from this group is selected at random, what is the probability that this person has B blood type?
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
1. There is a box which includes 4 coins. 3 of them are tricky that means if we flip these coins the chance of getting tails is 45%. On the other hand, the 4th coin has 50% probability of getting tails and 50% of getting heads. If we randomly pick up a coin and flip it, what is the % probability of getting 4 heads?
#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
1. Two classmates Bonnie and Frank take quizzes every month. They take English quizzes 3 out of 8 months of the school year randomly and Maths in the other months. Bonnie is better than Frank at English and gets higher points than Bonnie %80 of the time and Frank is better than Bonnie at Math at the %75 of the time. Suppose Bonnie got a higher point than Frank last month. What is the possibility that they had an English quiz?
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

# Group 4

1. Two dice roll. Sum of two faces is equal to 8. What is the probabilty that the first face equals to 4?
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
1. There are 250 men and 150 women in a group. Also, There are two courses Russian and German.

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
1. A stallholder has three types products which are t-shirt, pullover and jacket. Considering his market stall, it seems that it includes %30 t-shirts, %40 pullovers and %30 jackets. At the same time, it is known that %5 of t-shirts, %8 of pullovers and %2 of jackets are of small size.
1. 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))
2. What is the probability that it came from t-shirts?

(t*(ts))/A
## [1] 0.2830189

# Group 5

1. Two standard dice with 6 sides are thrown and the faces are recorded. Given that the sum of the two faces equals to 10, what is the probability that the first throw equals to 5?
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)}$

1. Components 1 and 2 are connected in parallel, so that subsystem works if either 1 or 2 works. Components 3 and 4 are connected in series, that subsystem works if both 3 and 4 work. Subsystems are connected in parallel as well. If each component’s probability of working is P(component works) = 0.9, calculate P(system works).

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
1. What is the probability that a woman has cancer if she has a positive mammogram result?
• One percent of women over 50 have breast cancer.
• Ninety percent of women who have breast cancer test positive on mammograms.
• Eight percent of women will have false positives

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

print(answer)
## [1] 0.1020408

$P(A|B) = \dfrac{P(B|A)P(A)}{P(B|A)P(A)+P(B|A')P(A')}$

# Group 7

1. Suppose there are 14 cards; 7 are red and 7 are green. Suppose we randomly choose 5 cards.
1. what is the probability that all are red ones.
2. What is the probability that at least two are red and two are green.

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)

1. Suppose we are rolling two dice and three coins.
1. what is the probability of getting three T if we know that the first one and the second one are Heads?
2. 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

1. 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