Programa de Maestría
Gestión de Tecnologías de
Información y Comunicación
(M-GTIC)
Nombre del Curso: Teoría de Señales
Febrero 03, 2010
2010 M. Arias
Probabilistic Modeling
Probability models:
Simplified approximations to reality
Detailed enough to capture important
characteristics of the random phenomenon
Useful as a prediction device
But… no so detailed difficult to use in
practice.
2010 M. Arias
2
Matlab Code
% This reads time and temperature data for an afternoon
% The times are in the first row, temps in the second row
timetemp= [24.2 22.7 30.5 28.6 25.5 32.0 28.6 26.5 25.3 26.0
24.4 24.8 20.6 25.5 21.4 23.7 23.9 25.2 27.4 28.3 28.8 26.6;25
31 36 33 19 24 27 25 16 14 22 23 20 25 25 23 27 30 33 32 35 24]
time = timetemp(1,:);
temp = timetemp(2,:);
% Plot the data and label the plot
plot(time,temp,'k+')
xlabel('Time')
ylabel('Temperature')
title('Temperatures one afternoon')
2010 M. Arias
3
Model: Abstraction of Reality
Questions:
Large x values tend to be paired with large y
values?
Or
Small x values with small y values?
Otherwise…
Large values of one of the variables tend to be
paired with small values of the other?
2010 M. Arias
4
A Scatter Diagram for Problem
2010 M. Arias
5
Matlab Code
% This reads the resting pulse rates (in beats per minutes)
% and the years of schooling of 12 individuals
% The Years of School are in the first row, Pulse rate with a
large number of years in school in the second row
data= [12 16 13 18 19 12 18 19 12 14 15 10;73 67 74 63 73 84 60
62 76 71 69 70]
Schooling = data(1,:);
Pulse_rate = data(2,:);
% Plot the data and label the plot
plot(Schooling,Pulse_rate,'k+')
xlabel('Years of School')
ylabel('Pulse rate')
title('Scatter diagram of years in school and pulse rate')
2010 M. Arias
6
A Scatter Diagram for Problem
2010 M. Arias
7
Analysis vs. Computer Simulation
If we have a model for the random phenomenon, then we
may carry out the experiment a large number of times to
obtain an approximate probability.
In Matlab e.g. a number in the interval (0,1) can be
produced with the simple statement x=rand(1,1). The
number is chosen “ at random”.
Similarly, for a continuous outcome experiment, generate a
“continuum ” of outcomes on a computer.
Matlab can produce numbers that follow a Gaussian curve
by the statement x=randn(1,1).
2010 M. Arias
8
Analysis vs. Computer Simulation
We analyze here the case of a number of person at a
business location talking on their respective phones
anytime between 9:00 AM and 9:10 AM. We ask for the
probability that 3 persons are on the phone
If we let p = 0.75 and N= 4
9
Analysis vs. Computer Simulation
MATLAB code
clear; clc; close all
N = 4;
p = 0.75;
for k = 1:N
comb = factorial(N)/(factorial(N-k)*factorial(k)) ;
P(k) = comb*p^k*(1-p)^(N-k);
end
stem(1:k,P); axis([0 5 0 0.5]);grid on
ylabel('P[k]');xlabel('k')
10
Analysis vs. Computer Simulation
0.5
0.45
0.4
0.35
P[k]
0.3
0.25
0.2
0.15
0.1
0.05
0
0
0.5
1
1.5
2
2.5
k
3
3.5
4
4.5
5
11
Analysis vs. Computer Simulation
12
Analysis vs. Computer Simulation
13
Analysis vs. Computer Simulation
clear; clc; close all
delta = 0.01;
t = 5:delta:6;
y = (1/sqrt(2*pi))*exp(-0.5*(t-7).^2);
area(t,y)
[Pr] = trapint(y,delta);
title('Gaussian PDF')
xlabel('t [min]');
ylabel('$\frac{1}{\sqrt{2\pi}}e ^{ [0.5(t7)^2]}$','Interpreter','latex','FontSize',
20)
14
Analysis vs. Computer Simulation
function [A] = trapint(x,delta)
% Numerical Integration
% using the trapezoid method
%Usage : [A] = trapint(x,delta)
N = length(x);
A = delta*(x(1)/2 + x(N)/2 + sum(x(2:end-1)));
end
15
Analysis vs. Computer Simulation
Gaussian PDF
0.25
0.2
0.15
0.1
0.05
0
5
5.2
5.4
5.6
5.8
6
t [min]
16
Analysis vs. Computer Simulation
Problem 1:10
A coin is tossed 12 times. The sequence observed is the
12-tuple (H H T H H T H H H H T H). Is this a fair coin?
17
Analysis vs. Computer Simulation
clear ; clc ; close all
% The sequence boserved is H H T H H T H H H H T H
% we assign a probability of p = 0.5 to both H and T
% because we assume is a fair coin
N = 12;
p = 0.5;
for k = 1:N
comb = factorial(N)/(factorial(N-k)*factorial(k)) ;
P(k) = comb*p^k*(1-p)^(N-k);
end
stem(1:N,P)
CONCLUSION?
18
Analysis vs. Computer Simulation
Problem 2:1
An experiment consists of tossing a fair coin twice. If a
head occurs on the first toss, we let a;i = 1 and if a tail
occurs we let xi = 0. The same assignment is used for
the outcome X2 of the second toss. Defining the
random variable as Y = X1X2, estimate the probabilities
for the different possible values of Y. Explain your
results.
19
Analysis vs. Computer Simulation
clear ; clc ; close all
N = 1000;
for i= 1:N
% toss first coin
n1 = rand;
if n1 <= 0.5
x1(i) = 1;
else
x1(i)= 0;
end
%toss second coin
n2 = rand;
if n2 <= 0.5
x2(i) = 1;
else
x2(i)= 0;
end
% calculate Y
y(i) = x1(i)*x2(i);
end
20
Analysis vs. Computer Simulation
%Draw histogram as a pdf approximation
bincenters = [0:0.5:1]';
bins
= length(bincenters);
h
= zeros(bins,1);
for i=1:length(y)
for k=1:bins
if y(i)>bincenters(k)-0.5/2 & y(i)<=bincenters(k)+0.5/2
h(k,1)=h(k,1)+1;
end
end
end
pxest=h/(2*N*0.5);
bar(bincenters,pxest);
ylabel('$P_y$','Interpreter','latex')
xlabel('$y = x_1 x_2$','Interpreter','latex');grid on
21
Analysis vs. Computer Simulation
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
-0.2
0
0.2
0.4
0.6
0.8
1
1.2
22
Analysis vs. Computer Simulation
Problems 1.10.1 & 1.11.4 (Yates’s book)
function N=ultrareliable6(n,q);
% n is the number of 6 component devices
%N is the number of working devices
for r=1:6,
W=rand(n,6)>q;
R=rand(n,1)>(q/2);
W(:,r)=R;
D=(W(:,1)&W(:,2)&W(:,3))|W(:,4);
D=D&(W(:,5)|W(:,6));
N(r)=sum(D);
end
2010 M. Arias
23
Analysis vs. Computer Simulation
A sample run for n = 100 trials and q = 0.2 yielded
these results:
ultrareliable6(100,0.2)
ans =
93 89 91 92 90 93
From the above, we see, for example, that replacing the
third component with an ultra reliable component resulted
in 91 working devices.
The results are fairly inconclusive in that replacing
devices 1, 2, or 3 should yield the same probability of device
failure.
2010 M. Arias
24
Analysis vs. Computer Simulation
If we experiment with n = 10, 000 runs, the results
are more definitive:
>> ultrareliable6(10000,0.2)
ans =
8738 8762 8806 9135 8800 8796
It is clear that replacing component 4 maximizes
the device reliability.
2010 M. Arias
25
Counting
if expt. A has n outcomes, and expt. B has k outcomes then performing
expts. A and B yields nk outcomes
n distinguishable objects (without replacement):
total number of k–permutations (ordered sequences of k objects)
n!
n(n 1)(n 2) ( n k 1)
(n k )!
total number of ways to choose k objects
n
n!
k k!( n k )!
“n choose k”
n distinguishable objects (with replacement)
total number of k–permutations
nk
2010 M. Arias
26
Independent trials
In n independent trials where
P[ success ] p
P[ failure ] 1 p
then
n k
P[ k sucesses in n trials] p (1 p ) n k
k
2010 M. Arias
27
Summary of Probability
In summary:
The probability theory provide us with the ability to
predict the behavior of random phenomena in the
long run.
Probability can serve as a valuable tool for
assesssment and decision making.
Applications:
Engineering
Medicine
Economics
Physics and others.
2010 M. Arias
28
References
Probability and Stochastic Processes: A Friendly
Introduction for Electrical and Computer
Engineers. (Chapter 1).
Introduction to Probability and Statistics for
Engineers and Scientists. Sheldon M. Ross
(Chapter 1).
http://www.wiley.com/college/yates
2010 M. Arias
29
Probability
Examples:
The probability that it will rain the next day
The probability that you will win the lottery
Common thread:
Presence of random experiment
A set of outcomes
Probabilities assigned to these outcomes
These attributes are common to all probabilistic
descriptions.
2010 M. Arias
30
2010 M. Arias