Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
133 views

Lab4 - Conditional Probability, Bayes' Theorem

The document contains examples of using conditional probability and Bayes' theorem to solve probability problems involving experiments with dice rolls, coin tosses, and other scenarios. MATLAB code is provided to simulate some of these experiments with large numbers of trials to estimate probabilities.

Uploaded by

A B
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
133 views

Lab4 - Conditional Probability, Bayes' Theorem

The document contains examples of using conditional probability and Bayes' theorem to solve probability problems involving experiments with dice rolls, coin tosses, and other scenarios. MATLAB code is provided to simulate some of these experiments with large numbers of trials to estimate probabilities.

Uploaded by

A B
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Applied Statistics,

Probability theory
and mathematical
statistics
CONDITIONAL PROBABILITY, BAYES'
THEOREM
Exercise 5.4 (M2)
Two dice are rolled. Find the probability that the sum of the numbers
obtained is 7 given the sum is odd.

𝐴−𝑡h𝑒 𝑠𝑢𝑚𝑖𝑠7
    ( 𝐴 ∨𝐵 )= 𝑃 ( 𝐴𝐵 )
𝑃
𝑃 ( 𝐵)

  ( 𝐴 𝐵 )= 6
6 7 8 9 10 11 12
𝑃
5 6 7 8 9 10 11 36
4 5 6 7 8 9 10
3 4 5 6 7 8 9
2 3 4 5 6 7 8   ( 𝐵 )= 18
𝑃
36
1 2 3 4 5 6 7
1 2 3 4 5 6
  ( 𝐴 ∨𝐵 )= 6/ 36 6
𝑃 = =1 /3
18/ 36 18
Exercise 5.5 (M3)
Two dice are rolled. Find the probability that at least one of them shows
six, given they show different values.

Hint:
6
5
(1;6)
(1;5)
(2;6)
(2;5)
(3;6)
(3;5)
(4;6)
(4;5)
(5;6)
(5;5)
(6;6)
(6;5)
𝐴 −𝑎𝑡 𝑙𝑒𝑎𝑠𝑡 𝑜𝑛𝑒 𝑠h𝑜𝑤𝑠6
 

4 (1;4) (2;4) (3;4) (4;4) (5;4) (6;4)   ( 𝐴 ∨𝐵 )= 𝑃 ( 𝐴𝐵 )


𝑃
3 (1;3) (2;3) (3;3) (4;3) (5;3) (6;3)
2 (1;2) (2;2) (3;2) (4;2) (5;2) (6;2)
𝑃 ( 𝐵)
  ( 𝐴 𝐵 )= 10
1 (1;1) (2;1) (3;1) (4;1) (5;1) (6;1)
1 2 3 4 5 6 𝑃
36
  ( 𝐵 )= 30
𝑃
36
  ( 𝐴 ∨𝐵 )= 10/36 10
𝑃 = =1 /3
30/36 30
Exercise 5.7
We know that at least one of the two kids in a family is a girl. Find the
probability of having also a boy in the family.

2
 
𝑃 ( 𝐴𝐵 ) 4
𝑃 ( 𝐴 ∨𝐵 )= = = 2/ 3
𝑃 ( 𝐵) 3
4
Exercise 5.8*
Choose two points randomly from the unit interval. Find the probability
that both points are closer to a previously specified end point of the
interval, given their distance is less than 1/2.

  1< 𝑦−𝑥< 1

Hint: 2 2
1
𝑦=
  𝑥+ 2   ( 𝐴 ∨𝐵 )= 𝑃 ( 𝐴𝐵 )
𝑃
𝑃 ( 𝐵)

𝑦=𝑥
  −
1
2
  ( 𝐵 )= 3
𝑃
1
 2 4

  ( 𝐴 𝐵 )= 1
𝑃
4
1
1
 2 𝑃  ( 𝐴 ∨𝐵 )=
3
Exercise 5.14
In a TV quiz show the player has to choose one from three envelopes. In
the first envelope there are 5 cards saying 'Sorry, next time', 3 cards
with 'You have won 100 euros' and 2 cards with 'You have won 500
euros'. The content of the second envelope: 2 cards 'Sorry, next time', 7
cards 'You have won 100 euros' and 1 card 'You have won 500 euros'.
The third envelope contains only 'Sorry, next time' cards. The player
chooses randomly an envelope and from the chosen envelope he
chooses a card. What is the probability that the player wins 500 euros?

 
𝐴 − 𝑤𝑖𝑛𝑛𝑖𝑛𝑔500 𝑒𝑢𝑟𝑜𝑠
  ( 𝐴 ∨𝐵 1) = 2
𝑃   ( 𝐴 ∨𝐵 2) = 1
𝑃   ( 𝐴 ∨𝐵 3 )= 0
𝑃
10 10 10

  ( 𝐴 ) =𝑃 ( 𝐴∨𝐵1 ) P ( B1 ) + 𝑃 ( 𝐴∨𝐵2 ) P ( B 2 )+ 𝑃 ( 𝐴∨𝐵3 ) P ( B3 )= 1


𝑃
10
Exercise 5.19
Rust Rider cars are produced in four factories. The first factory produces
200 cars per day, the second 320, the third 270, while the fourth 210.
The refuse ratios for the factories are 2%; 5%; 3% and 1%, respectively.
We bought a Rust Rider and we found it perfect. What is the probability
that it had been produced in the fourth factory?
 
𝐴 −𝑡h𝑒 𝑐𝑎𝑟 𝑖𝑠 𝑝𝑒𝑟𝑓𝑒𝑐𝑡
𝑃( 𝐴∨𝐵4) 𝑃( 𝐵4)
  ( 𝐵 4∨ 𝐴 ) =
𝑃 4

∑ 𝑃 ( 𝐴|𝐵 𝑖 ) 𝑃 ( 𝐵𝑖 )
𝑖=1

  ( 𝐵 4∨ 𝐴 ) = 2079
𝑃
9698
Exercise 5.22
 
During one of his journeys Ulysses arrives to a triple turnout. The first
road leads to Athens, the second to Mycenae, the third to Sparta.
Athenians are merchants, they like to sham their guests and in two third
of the cases they lie. Mycenaean are a bit better: they lie only in each
second case. Due to their strict traditions Spartans are honest, they
always tell the truth. Ulysses does not know where to go (the directions
are not indicated), so he chooses a road randomly. After arriving to the
city at the end of the road Ulysses asks a local man, how much is and
the answer is 4. What is the probability that Ulysses has arrived to
Athens?

𝐴−𝑎𝑟𝑟𝑖𝑣𝑒𝑑𝑡𝑜 𝐴𝑡h𝑒𝑛𝑠
 

  ( 𝐴 ∨𝐵 )= 𝑃 ( 𝐵∨ 𝐴 ) 𝑃 ( 𝐴 ) = 2
𝑃
𝑃 ( 𝐵) 11
Exercise 5.24
In an office equipped with mechanized administration three machines
classify the files. The first can process 10 files per day, the second 15,
while the third 25. The average numbers of misclassified files are 0.3,
0.9 and 0.5 per day, respectively. We choose a file randomly from the
daily production and we find that it has been misclassified. What is the
probability that the file was processed by the first machine?

 
𝐴 − 𝑚𝑖𝑠𝑐𝑙𝑎𝑠𝑠𝑖𝑓𝑖𝑒𝑑
𝑃 ( 𝐴 ∨ 𝐵𝑖 ) 𝑃 ( 𝐵𝑖 )
  ( 𝐵 𝑖∨ 𝐴 ) =
𝑃 3

∑ 𝑃 ( 𝐴|𝐵 𝑗 ) 𝑃 ( 𝐵 𝑗 )
𝑗=1

3 1
  ∗
100 5 3
𝑃 ( 𝐵 1∨ 𝐴 ) = =
3 10 6 15 2 25 17
∗ + ∗ + ∗
100 50 100 50 100 50
Exercise M1
Write a MATLAB code, that simulates 100000000 coin tosses and stores
the result of all the tosses in a single row vector! (head=0, tail=1)
Count the number of heads and tails and display the result!

tic tic
n=100000000 v2=randi(2,1,100000000)-1;
v=rand(1,n); sum(v2)
for i=1:n toc
if v(i)<0.5
v(i)=0;
else v(i)=1;
end
end
sum(v)
toc
Exercise M2
Write a MATLAB code, that simulates the experiment in Exercise 5.4!
Two dice are rolled. Find the probability that the sum of the numbers
obtained is 7 given the sum is odd.
s=0;
k=0;
for i=1:1000000
p=randi(6,1,2);
if rem(sum(p),2)==1
s=s+1;
if sum(p)==7
k=k+1;
end
end
end
disp('Number of cases when the sum is odd:')
s
disp('Number of cases when the sum is seven:')
k
k/s
Exercise M3
Write a MATLAB code, that simulates the experiment in Exercise 5.5!
Two dice are rolled. Find the probability that at least one of them shows
six, given they show different values.
s=0;
k=0;
for i=1:1000000
p=randi(6,1,2);
if p(1)~=p(2)
s=s+1;
if p(1)==6 | p(2)==6
k=k+1;
end
end
end
disp('Number of cases when they show different values:')
s
disp('Number of cases when at least one of them shows
six:')
k
k/s

You might also like