152-background - University of California, Santa Cruz

Download Report

Transcript 152-background - University of California, Santa Cruz

CMPE 252A:
Computer Networks
Review Set:
Quick Review of
Probability Theory and
Random Processes
1
Why Probability Theory?



Information is exchanged in a computer network in a
random way, and events that modify the behavior of links
and nodes in the network are also random
We need a way to reason in quantitative ways about the
likelihood of events in a network, and to predict the
behavior of network components.
Example 1:


Measure the time between two packet arrivals into the
cable of a local area network.
Determine how likely it is that the interarrival time
between any two packets is less than T sec.
2
Probability Theory


A mathematical model used to quantify the
likelihood of events taking place in an
experiment in which events are random.
It consists of:
A sample space: The set of all possible
outcomes of a random experiment.
 The set of events: Subsets of the sample
space.
 The probability measure: Defined according to a
probability law for all the events of the
sample space.

3
Random Experiment


A random experiment is specified by stating
an experimental procedure and a set of
measurements and observations.
Example 2:
We count the number of packets received
correctly at a base station in a wireless LAN
during a period of time of T sec.
We want to know how likely it is that the
next packet received after T sec is correct.
4
Our Modeling Problem ...


We want to reason in quantitative terms
about the likelihood of events that can be
observed.
This requires:



Describing all the events in which we are
interested for the experiment.
Combining events into sets of events that are
interesting (e.g., all packets arriving with 5 sec.
latency)
Assigning a number to each of those events
reflecting the likelihood that they occur.
5
Probability Law


Probability of an event: A number
assigned to the event reflecting the
likelihood with which it can occur or has
been observed to occur.
Probability Law: A rule that assigns
probabilities to events in a way that reflects
our intuition of how likely the events are.
What we need then is a formal way of assigning
these numbers to events and any combination of
events that makes sense in our experiments!
6
Probability Law




Let E be a random experiment (r.e.)
Let A be an event in E
The probability of A is denoted by P(A)
A probability law for E is a rule that assigns P(A)
to A in a way that the following conditions, taken
from our daily experience, are satisfied:



A may or may not take place; it has some
likelihood (which may be 0 if it never occurs).
Something must occur in our experiment.
If one event negates another, then the likelihood
that either occurs is the likelihood that one
occurs plus the likelihood that the other occurs.
7
Probability Law


More formally, we state the same as follows.
A probability law for E is a rule that assigns a
number P(A) to each event A in E satisfying
the following axioms:
AI:
0  P(A)
P( S )  1
 AII:
A  B    P( A  B)  P(A)  P(B)
 AIII:

Everything else is derived from these axioms!
8
Important Corollaries
1. A1 , A2 , ... An
Ai  Aj    i  j  P( Ak )   P( Ak )
k
k
2. P( Ac )  1  P( A)
3. P( A)  1
4. P()  0
5. P( A  B)  P( A)  P( B)  P( A  B)
9
Probability Law
1  P( S )
S
P ( A)
A
P(x)
x



0  P()
All probabilities must be in [0, 1]
The sum of probabilities must be at most 1
10
Conditional Probability
Events of interest occur within some context,
and that context changes their likelihood.
time
packet collisions
time
interarrival times
We are interested in events occurring given that
others take place!
11
Conditional Probability


The likelihood of an event A occurring given
that another event B occurs is smaller than
the likelihood that A occurs at all.
We define the conditional probability of A
given B as follows:
P( A  B)
P( A | B) 
for P( B)  0
P( B)
We require P(B) > 0 because we know B occurs!
12
Theorem of Total
Probability


Purpose is to divide and conquer
We can describe how likely an event is by
partitioning it into mutually exclusive pieces.
busy period
idle period busy period
success
B1
failure
B2
time
B3
13
Theorem of Total
Probability
B2
B1
A  B5
A
Bn
...
Intersections of A with B’s are mutually exclusive
P( A)   P( A | Bi ) P( Bi )   P( A  Bi )
i
i
14
Independence of Events







In many cases, an event does not depend on prior events,
or we want that to be the case.
Example: Our probability model should not have to account
for the entire history of a LAN.
Independence of an even with respect to another means
that its likelihood does not depend on that other event.
A is independent of B if P(A | B) = P(A)
B is independent of A if P(B | A) = P(B)
So the likelihood of A does not change by
knowing about B and viceversa!
This also means:
P( A  B)  P( A) P( B)
15
Random Variables



We are not interested in describing the likelihood
of every outcome of an experiment explicitly.
We are interested in quantitative properties
associated with the outcomes of the experiment.
Example:


What is the probability with which each packet
sent in an experiment is received correctly?
We don’t really care!
What is the probability of receiving no packets
correctly within a period of T sec.?
We care! This may make a router delete a
neighbor!
16
Random Variables




We implicitly use a measurement that assigns a numerical
value to each outcome of the experiment.
The measurement is [in theory] deterministic; based on
deterministic rules.
The randomness of the observed values of the
measurement is completely determined by the randomness
of the experiment itself.
A random variable X is a rule that assigns a
numerical value to each outcome of a
random experiment
Yes, it is really a function!
17
Random Variables

Definition: A random variable X on a sample
space S is a function X: S ->R that assigns a
real number X(s) to each sample point s in S.
S
s1

X (s2 )
X (s1 )
s2
s3
s 4 s5

0
S X  {X (si ) | si  S}  
X (s4 )  X (s5 )
which is called the event space
18
Random Variables


Purpose is to simplify the description of the problem.
We will not have to define the sample space!
1
S
s
P( X ( s )  x)
0

X ( s)  x

Possible values of X
19
Types of Random Variables

Discrete and continuous: Typically used
for counting packets or measuring time
2
3
4
intervals. 1
time
t
0
next packet
Busy period
time
time?
20
Discrete Random Variables


We are interested in the probability that a discrete random
variable X (our measurement!) equals a certain value or
range of values.
Example:
We measure the delay experienced by each packet sent from one host to
another over the Internet; say we sent 1M packets (we have 1M delay
measurements). We want to know the likelihood with which any one
packet experiences a delay of 5 ms or less.

Probability Mass Function (pmf) of a random
variable X :
The probability that
X assumes a given value x
P( X  x)  pX ( x)
21
Discrete Random Variables
Cumulative Distribution Function (cdf) of a
random variable X: The probability that X
takes on any value in the interval (, x]
FX ( x)  P( X  x)
The pdf and pmf of a random variable are just
probabilities and obey the same axioms AI to
AIII. Therefore,
0  FX ( x)  1; lim x  FX ( x)  1; lim x FX ( x)  0
FX (a )  FX (b) for a  b
P (a  X  b)  FX (b)  FX (a )
22
Continuous Random Variables



The probability that a continuous r.v. X assumes a given
value is 0.
Therefore, we use the probability that X assumes a range
of values and make that length of that range tend to 0.
The probability density function (pdf) of X, if it exists,
is defined in terms of the cdf of X as
dFX ( x)
f X ( x) 
dx
b
P(a  X  b)   f X (x)dx; FX ( x) 
a
x
f
X
(t )dt  P(    X  x)


if x   then  f X (t )dt  1, because pdf is a probability

23
What We Will Use

We are interested in:
 Using the definitions of well-known
r.v.s to compute probabilities
 Computing average values and
deviations from those values for
well-known r.v.s
24
Mean and Variance
VC2
2
6
A
C
1
3


B
4
VC1
For VC1 use 3
For VC2 use 2
…..
For VCn use 3
7
5
D
What is the average queue length at each
router?
What is our worst case queue?
25
Mean and Variance
Expected value or mean of X:
E ( X )   xk p X (k ) for d.r.v.
k

E ( X )   tf X (t )dt
for c.r.v

Mean is always defined for us!
queue size
too much?
mean
time
26
Variance
Describes how much a r.v. deviates from its
average value, i.e., D = X - E(X)
We are only interested in the magnitude of
the deviation, so we use D2  ( X  E( X ))2
The variance of a r.v. is defined as the mean
squared variation E ( D 2 )
Var( X )   2  E([ X  E( X )]2 )
Important relation: Var( X )  E( X 2 )  E 2 ( X )
27
Properties of Mean and Variance
E (aX  b)  aE( X )  b; E (b)  b
Var (c)  0
Var ( X  c)  Var ( X )
Var (cX )  c Var ( X )
2
Useful when we discuss amplifying random
variables or adding constant biases.
28
Examples of Random Variables


We are interested in those r.v. that permit us to
model system behavior based on the present state
alone.
We need to





count arrivals in a time interval
count the number of times we need to repeat
something to succeed
count the number of successes and failures
measure the time between consecutive arrivals
The trick is to map our performance questions into
the above four types of experiments
29
Bernoulli Random Variable



Let A be an event related to the outcomes
of a random experiment.
X = 1 if outcome occurs and 0 otherwise
This is the Bernoulli r.v. and has two
possible outcomes: success (1) or
failure (0)
PX (0)  P0  P( X  0)  q  1  p
PX (1)  P1  P( X  1)  p  1  q
We use it as a building block for other types of counting
30
Geometric Random Variable


Used to count the number of attempts needed to
succeed doing something.
Example: How many times do we have to
transmit a packet over a broadcast radio
channel before it is sent w/o interference?
failure
failure
failure
success!
time
Assume that each attempt is independent of any prior
attempt!
Assume each attempt has the same probability of success (p)
31
Geometric Random Variable

We want to count the number k of trials needed for the first
success in a sequence of Bernoulli trials!
p  probability of success in a trial
p X (k )  P( X  k )  (1  p) k 1 p; k  1,2,...
Why this is the case is a direct consequence of assuming
independent Bernoulli trials, each with the same probability of success:
k-1 failures needed before the last successful trial
Memoryless property: The probability of having a success in
k additional trials having experienced n failures is the same as
the probability of success in k trials before the n failed trails
P( X  n  k | X  n)  P( X  k )
32
Binomial Random Variable

X denotes the number of times success occurs in n
independent Bernoulli trials.
Consider the specificoutcomes  S such that
s  (1, 1, 1, ... , 1, 0, 0, ... , 0); where1  success
1
k k 1
n; we havek 1's and n-k 0's
Let Ai  success in triali, then
s  A1  A2  ... Ak  Akc1  ... Anc
P ( Ai )  p; P ( A )  1  P( A)  1  p  q
c
Because trialsare independent :
P(s)  P( A1 ) P( A2 )....P( Ak ) P( A )...P( A )  p (1  p)
c
k 1
c
n
k
nk
33
Binomial Random Variable
P(s)  P( A1 )P( A2 )....P( Ak )P( Akc1 )...P( Anc )  pk (1  p)nk
n
T hereare   differentways to choosek positions
k
n
n!
for 1's in then slots,and   
 k  (n  k )!k!
Because each outcome is mutually exclusive of the others:
 n k

 k
n!
nk
 p (1  p) nk
Pn (k )    p (1  p)  
k
 (n  k )!k! 
0k n
34
Poisson Random Variable





We use this r.v. in cases where we need to count event
occurrences in a time period.
An event occurrence will typically be a packet arrival.
Arrivals are assumed to occur at random over a time
interval.
The time interval is (0, t]
We divide the time interval into n small subintervals of
length t / n  t
• The probability of a new arrival in a given subinterval is
defined to be t
•

is constant, independent of the subinterval.
35
Poisson Random Variable
Make n   and t  0 :
T heprobability of more thanone arrivalin t is negligible
comparedto theprobability of having0 or 1 arrivals.
By assumption, whether or not an event occurs in a subinterval is
independent of the outcomes in other subintervals.
We have:
t
arrival
time
….
0
1
2
3
k
t
1 2 3 4
n
A sequence of n independent Bernoulli trials; with X being
the number of arrivals in (0, t]
36
Poisson Random Variable
 n k
Pn (k )    p (1  p) nk ; k is thenumber of arrivals
k
p  P{arrivalin t  t / n}  t  t / n
P{k arrivalsin [0,t ]}  P( X  k )  Pk 
n!
(n  k )!k!

 (t ) k
n!
Rearrangeto get : Pk   k

 n (n  k )! k!
t  
 t 
1  n 


t 
n

1  n  1  n 
n k
 t 
n
 
k
k
Make n   and t  0, then:
2t)..(
 n((n
t )1)(n  
 n  k  1)  (t )
Pk  (1)
1 k 
 k!

 k!  nn 

x
k
n
k
 t  k
1  n  1


 1
and also e  limx 1   ; with x  n
 x
n
37
Poisson Random Variable
k
t   t
Pk  P{k arrivals in (0,
t]} 
k!
e
P0  P{0 arrivalsin (0,t ]}  et
P{some arrivalsin (0,t ]}  1  P0  1  et



We see that the Poisson r.v. is the result of an
approximation of i.i.d. arrivals in a time interval.
We will say “arrivals are Poisson” meaning we can use the
above formulas to describe packet arrivals
The probability of 0 arrivals in [0, t] plays a key role in our
treatment of interarrival times.
38
Important Properties of
Poisson Arrivals
• The parameter



 is called the arrival rate
The aggregation of Poisson sources is a Poisson
source.
If packets from a Poisson source are routed such
that a path is chosen independently with
probability p, that stream is also Poisson, with
rate p times the original rate.
It turns out that the time of a given Poisson
arrival is uniformly distributed in a time interval
39
Exponential Random Variable

Consider the Poisson r.v., then
P0  et
• Let Y be the time interval from a time origin (chosen
arbitrarily) to the first arival after that origin
• Let X ( )  Number of arrivalsin (0, ] then
P(Y   )  P( X ( )  0)  e
 
• We can obtain now a c.d.f. for Y as follows:
FY ( )  P(Y   )  1  P(Y   )  1  e ;   0
and the p.d.f. of Y is then
d
fY ( )  P(Y   )  e  ;   0
dt
40
Memoryless Property of
Exponential Random Variable

After waiting h sec. for the first arrival, the probability
that it occurs after t sec. equals the prob. that the
first arrival occurs after t sec.

Knowing that we have waited any amount of time does
not improve our knowledge of how much longer we’ll
have to wait!
P(Y  t  h | Y  t )  P(Y  h)
time
time?
time >t ?
time > t?
41
Mean and Variance Results
Exponential:
E(Y )  1/ ;  2  1/ 2
Poisson:
E( X )   2  t
Geometric:
E( X )  1/ p;  2  q / p 2
Binomial:
E( X )  np;  2  npq
You have to memorize these!
You should be able to derive any of the above
42
Random Processes

Definition: A random process is a family of
random variables {X(t) | t is in T } defined on a
given sample space, and indexed by a parameter
t, where t varies over an index set T.
state
space of
random
process
X(t5) is a R.V.
x
x
x
x
x
x
x
x
x
x
x
t1 t 2
t3
t4
a state of X(t)
t
t5
43
Poisson Process



We assume that events occur at random instants of time
at an average rate of lambda events per second.
Let N(t) be the number of event occurrences (e.g., packet
arrivals) in (0,t].
N(t) is a non-decreasing, integer-valued, continuous time
random process.
5
4
3
2
1
a1
a r.v.
t
a2
a3
N (t1 )  4
a r.v.
a4
a5
N (t2 )  4
44
Poisson Process

As we did for the case of the Poisson r.v., we divide the
time axis into very small subintervals, such that



The probability of more than one arrival in a subinterval is much
smaller than the probability of 0 or 1 arrivals in the subinterval.
Whether or not an arrival occurs in a subinterval is independent of
what takes place in any other subinterval.
We end up with the same Binomial counting process and
with the length of the subintervals going to 0 we can
approximate:
P[ N (t )  k ]  P{k arrivalsin

t k t
(0,t ]} 
e ,
k!
k  0,1,...
Again, inter arrival times are exponentially distributed with
parameter lambda
45
Poisson Process




Why do we say that arrivals occur “at random” with a
Poisson process?
Suppose that we know that only one arrival occurs in (0, t]
and x is the arrival time of the single arrival.
Let N(x) be the number of arrivals up to time x, 0 < x ≤ t
Then:
N(t) -N(x) = increment of arrivals in (x, t]
P[ X  x]  P{N ( x)  1 | N (t )  1}
P{N ( x)  N (t )  1} P{N ( x)  1 and N (t )  N ( x)  0}


P{N (t )  1}
P{N (t )  1}
46
Poisson Process

Arrivals in different intervals are independent.
P{N ( x)  1} P{N (t )  N ( x)  0}
P[ X  x] 
P{N (t )  1}
[(x)e  x ][e- (t -x) ] x
P[ X  x] 

t
te
t
The above probability corresponds to the
uniform distribution!
Hence, in the average case, a packet arrives in the middle of
a fixed time interval with Poisson arrivals
47