Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

'''1.

John is going to graduate from an industrial engineering


department in a university by the end of the
semester. After being interviewed at two companies he likes, he
assesses that his probability of getting an
offer from company A is 0.8, and his probability of getting an offer
from company B is 0.6. If he believes
that the probability that he will get offers from both companies is
0.5, what is the probability that he will
get at least one offer from these two companies?'''

prob_A = 0.8
prob_B = 0.6
prob_both = 0.5

prob_at_least_one = prob_A + prob_B - prob_both

print("Probability of getting at least one offer:", prob_at_least_one)

'''2. From a city, three news papers A,B, & C are being published. A
is read by 20%, B is read by 16%, C is
read by 14%, both A and B are read by 8%, both A and C are read by 5%,
both B and C are read by 4%
and all three A, B, & C are read by 2%. What is the percentage of the
population that read at least one
paper.'''

prob_A = 0.20
prob_B = 0.16
prob_C = 0.14
prob_AB = 0.08
prob_AC = 0.05
prob_BC = 0.04
prob_ABC = 0.02

prob_at_least_one = prob_A + prob_B + prob_C - prob_AB - prob_AC -


prob_BC + prob_ABC

percentage_at_least_one = prob_at_least_one * 100

print("Percentage of population that read at least one paper:",


percentage_at_least_one)

'''3. Three urns I , II and III contain respectively 2 white and 3


black balls, 3 white and 4 black balls, and 4
white and 5 black balls. One of the urns is chosen randomly, the
probability of each urn chosen being
equal. Then one ball is drawn at random from the urn chosen and found
to be black. What is the
probability that urn I, II or III was chosen?'''

prob_choose_urn = 1/3
prob_black_given_urn = [3/5, 4/7, 5/9]

prob_black = sum(prob_choose_urn * p_black for p_black in


prob_black_given_urn)

prob_choose_urn_given_black = [prob_choose_urn * p_black_given_urn /


prob_black for p_black_given_urn in prob_black_given_urn]

prob_at_least_one_urn_chosen = sum(prob_choose_urn_given_black)

print("Probability of choosing urn I, II, or III given a black ball


was drawn:", prob_at_least_one_urn_chosen)

'''4. Three machines A, B and C produce respectively 60%, 30%, 10%, of


the total number of items of a factory.
The percentages of defective output of these machines are respectively
2%, 3% and 4%. An item is selected
at random and is found defective. Find the probability that the item
was produced by machine C. '''

prob_machine_C = 0.10
prob_defective_given_C = 0.04

prob_machine_A = 0.60
prob_defective_given_A = 0.02

prob_machine_B = 0.30
prob_defective_given_B = 0.03

prob_defective = (prob_machine_C * prob_defective_given_C) +


(prob_machine_A * prob_defective_given_A) + (prob_machine_B *
prob_defective_given_B)

prob_machine_C_given_defective = (prob_machine_C *
prob_defective_given_C) / prob_defective

print("Probability that the item was produced by machine C given it's


defective:", prob_machine_C_given_defective)

'''5. In a class, 70% are boys and 30% are girls. 5% of boys, 3% of
the girls are irregular to the classes. What
is the probability of a student selected at random is irregular to the
classes and what is the probability that
the irregular student is a girl? '''

prob_boy = 0.70
prob_girl = 0.30

prob_irregular_given_boy = 0.05
prob_irregular_given_girl = 0.03

prob_irregular = (prob_irregular_given_boy * prob_boy) +


(prob_irregular_given_girl * prob_girl)

prob_girl_given_irregular = (prob_irregular_given_girl * prob_girl) /


prob_irregular

print("Probability of a student being irregular to the classes:",


prob_irregular)
print("Probability that an irregular student is a girl:",
prob_girl_given_irregular)

Probability of getting at least one offer: 0.8999999999999999


Percentage of population that read at least one paper: 35.0
Probability of choosing urn I, II, or III given a black ball was
drawn: 1.0000000000000002
Probability that the item was produced by machine C given it's
defective: 0.16
Probability of a student being irregular to the classes: 0.044
Probability that an irregular student is a girl: 0.20454545454545453

Name – Neerav Babel


USN No. - 23BTRCT088

Branch – CSE*
Section – B

Subject - Probablity and Vector Space

Subject Code - 23TBSMA21

**LAB ASSIGNMENT - 1**

You might also like