review of probability - scientific computing and …review of probability objective to provide...

74
Digital Image Processing, 3rd ed. www.ImageProcessingPlace.com © 1992–2008 R. C. Gonzalez & R. E. Woods Gonzalez & Woods Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on probability and random variables. Review Probability & Random Variables

Upload: others

Post on 19-Jan-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Objective

To provide background material in support of topics in DigitalImage Processing that are based on probability and randomvariables.

ReviewProbability & Random Variables

Page 2: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Sets and Set Operations

Probability events are modeled as sets, so it is customary tobegin a study of probability by defining sets and some simpleoperations among sets.

A set is a collection of objects, with each object in a set oftenreferred to as an element or member of the set. Familiarexamples include the set of all image processing books in theworld, the set of prime numbers, and the set of planetscircling the sun. Typically, sets are represented byuppercase letters, such as A, B, and C, and members of setsby lowercase letters, such as a, b, and c.

Page 3: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Sets and Set Operations (Con’t)

We denote the fact that an element a belongs to set A by

If a is not an element of A, then we write

A set can be specified by listing all of its elements, or bylisting properties common to all elements. For example,suppose that I is the set of all integers. A set B consistingthe first five nonzero integers is specified using thenotation

Page 4: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Sets and Set Operations (Con’t)

The set of all integers less than 10 is specified using thenotation

which we read as "C is the set of integers such that eachmembers of the set is less than 10." The "such that" condition isdenoted by the symbol “ | “ . As shown in the previous twoequations, the elements of the set are enclosed by curly brackets.

The set with no elements is called the empty or null set, denotedin this review by the symbol Ø.

Page 5: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Sets and Set Operations (Con’t)

Two sets A and B are said to be equal if and only if theycontain the same elements. Set equality is denoted by

If every element of B is also an element of A, we say that B isa subset of A:

If the elements of two sets are not the same, we say that the setsare not equal, and denote this by

Page 6: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Sets and Set Operations (Con’t)

Finally, we consider the concept of a universal set, which wedenote by U and define to be the set containing all elements ofinterest in a given situation. For example, in an experiment oftossing a coin, there are two possible (realistic) outcomes: headsor tails. If we denote heads by H and tails by T, the universal setin this case is {H,T}. Similarly, the universal set for theexperiment of throwing a single die has six possible outcomes,which normally are denoted by the face value of the die, so inthis case U = {1,2,3,4,5,6}. For obvious reasons, the universalset is frequently called the sample space, which we denote by S.It then follows that, for any set A, we assume that Ø ⊆ A ⊆ S,and for any element a, a ∈ S and a ∉ Ø.

Page 7: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Some Basic Set Operations

The operations on sets associated with basic probability theoryare straightforward. The union of two sets A and B, denotedby

is the set of elements that are either in A or in B, or in both. Inother words,

Similarly, the intersection of sets A and B, denoted by

is the set of elements common to both A and B; that is,

Page 8: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Set Operations (Con’t)

Two sets having no elements in common are said to be disjointor mutually exclusive, in which case

The complement of set A is defined as

Clearly, (Ac)c=A. Sometimes the complement of A is denotedas .The difference of two sets A and B, denoted A − B, is the setof elements that belong to A, but not to B. In other words,

Page 9: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Set Operations (Con’t)

It is easily verified that

The union operation is applicable to multiple sets. Forexample the union of sets A1,A2,…,An is the set of points thatbelong to at least one of these sets. Similar comments applyto the intersection of multiple sets.

The following table summarizes several important relationshipsbetween sets. Proofs for these relationships are found in mostbooks dealing with elementary set theory.

Page 10: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Set Operations (Con’t)

Page 11: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Set Operations (Con’t)

It often is quite useful to represent sets and sets operations ina so-called Venn diagram, in which S is represented as arectangle, sets are represented as areas (typically circles), andpoints are associated with elements. The following exampleshows various uses of Venn diagrams.Example: The following figure shows various examples ofVenn diagrams. The shaded areas are the result (sets of points)of the operations indicated in the figure. The diagrams in the toprow are self explanatory. The diagrams in the bottom row areused to prove the validity of the expression

which is used in the proof of some probability relationships.

Page 12: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Set Operations (Con’t)

Page 13: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Relative Frequency & Probability

A random experiment is an experiment in which it is notpossible to predict the outcome. Perhaps the best knownrandom experiment is the tossing of a coin. Assuming thatthe coin is not biased, we are used to the concept that, onaverage, half the tosses will produce heads (H) and theothers will produce tails (T). This is intuitive and we donot question it. In fact, few of us have taken the time toverify that this is true. If we did, we would make use of theconcept of relative frequency. Let n denote the totalnumber of tosses, nH the number of heads that turn up, andnT the number of tails. Clearly,

Page 14: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Relative Frequency & Prob. (Con’t)

Dividing both sides by n gives

The term nH/n is called the relative frequency of the event wehave denoted by H, and similarly for nT/n. If we performed thetossing experiment a large number of times, we would find thateach of these relative frequencies tends toward a stable, limitingvalue. We call this value the probability of the event, anddenoted it by P(event).

Page 15: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Relative Frequency & Prob. (Con’t)

In the current discussion the probabilities of interest are P(H) andP(T). We know in this case that P(H) = P(T) = 1/2. Note that theevent of an experiment need not signify a single outcome. Forexample, in the tossing experiment we could let D denote theevent "heads or tails," (note that the event is now a set) and theevent E, "neither heads nor tails." Then, P(D) = 1 and P(E) = 0.

The first important property of P is that, for an event A,

That is, the probability of an event is a positive numberbounded by 0 and 1. For the certain event, S,

Page 16: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Relative Frequency & Prob. (Con’t)

Here the certain event means that the outcome is from theuniversal or sample set, S. Similarly, we have that for theimpossible event, Sc

This is the probability of an event being outside the sampleset. In the example given at the end of the previousparagraph, S = D and Sc = E.

Page 17: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Relative Frequency & Prob. (Con’t)

The event that either events A or B or both have occurred issimply the union of A and B (recall that events can be sets).Earlier, we denoted the union of two sets by A ∪ B. One oftenfinds the equivalent notation A+B used interchangeably indiscussions on probability. Similarly, the event that both A andB occurred is given by the intersection of A and B, which wedenoted earlier by A ∩ B. The equivalent notation AB is usedmuch more frequently to denote the occurrence of both events inan experiment.

Page 18: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Relative Frequency & Prob. (Con’t)

Suppose that we conduct our experiment n times. Let n1 be thenumber of times that only event A occurs; n2 the number oftimes that B occurs; n3 the number of times that AB occurs; andn4 the number of times that neither A nor B occur. Clearly,n1+n2+n3+n4=n. Using these numbers we obtain the followingrelative frequencies:

Page 19: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Relative Frequency & Prob. (Con’t)

and

Using the previous definition of probability based on relativefrequencies we have the important result

If A and B are mutually exclusive it follows that the set AB isempty and, consequently, P(AB) = 0.

Page 20: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Relative Frequency & Prob. (Con’t)

The relative frequency of event A occurring, given that event Bhas occurred, is given by

This conditional probability is denoted by P(A/B), where wenote the use of the symbol “ / ” to denote conditionaloccurrence. It is common terminology to refer to P(A/B) as theprobability of A given B.

Page 21: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Relative Frequency & Prob. (Con’t)

Similarly, the relative frequency of B occurring, given that A hasoccurred is

We call this relative frequency the probability of B given A, anddenote it by P(B/A).

Page 22: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Relative Frequency & Prob. (Con’t)

A little manipulation of the preceding results yields thefollowing important relationships

and

The second expression may be written as

which is known as Bayes' theorem, so named after the 18thcentury mathematician Thomas Bayes.

Page 23: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Relative Frequency & Prob. (Con’t)

Example: Suppose that we want to extend the expression

to three variables, A, B, and C. Recalling that AB is the same asA ∩ B, we replace B by B ∪ C in the preceding equation toobtain

The second term in the right can be written as

From the Table discussed earlier, we know that

Page 24: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Relative Frequency & Prob. (Con’t)

so,

Collecting terms gives us the final result

Proceeding in a similar fashion gives

The preceding approach can be used to generalize theseexpressions to N events.

Page 25: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Relative Frequency & Prob. (Con’t)

If A and B are statistically independent, then P(B/A) = P(B) andit follows that

and

It was stated earlier that if sets (events) A and B are mutuallyexclusive, then A ∩ B = Ø from which it follows that P(AB) =P(A ∩ B) = 0. As was just shown, the two sets are statisticallyindependent if P(AB)=P(A)P(B), which we assume to benonzero in general. Thus, we conclude that for two events tobe statistically independent, they cannot be mutuallyexclusive.

Page 26: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Relative Frequency & Prob. (Con’t)

For three events A, B, and C to be independent, it must be truethat

and

Page 27: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Relative Frequency & Prob. (Con’t)

In general, for N events to be statistically independent, it must betrue that, for all combinations 1 ≤ i ≤ j ≤ k ≤ . . . ≤ N

Page 28: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Relative Frequency & Prob. (Con’t)

Example: (a) An experiment consists of throwing a single dietwice. The probability of any of the six faces, 1 through 6,coming up in either experiment is 1/6. Suppose that we want tofind the probability that a 2 comes up, followed by a 4. Thesetwo events are statistically independent (the second event doesnot depend on the outcome of the first). Thus, letting Arepresent a 2 and B a 4,

We would have arrived at the same result by defining "2followed by 4" to be a single event, say C. The sample set ofall possible outcomes of two throws of a die is 36. Then,P(C)=1/36.

Page 29: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Relative Frequency & Prob. (Con’t)

Example (Con’t): (b) Consider now an experiment in whichwe draw one card from a standard card deck of 52 cards. Let Adenote the event that a king is drawn, B denote the event that aqueen or jack is drawn, and C the event that a diamond-facecard is drawn. A brief review of the previous discussion onrelative frequencies would show that

and

Page 30: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Relative Frequency & Prob. (Con’t)

Example (Con’t): Furthermore,

and

Events A and B are mutually exclusive (we are drawing only onecard, so it would be impossible to draw a king and a queen orjack simultaneously). Thus, it follows from the precedingdiscussion that P(AB) = P(A ∩ B) = 0 [and also that P(AB) ≠P(A)P(B)].

Page 31: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Relative Frequency & Prob. (Con’t)

Example (Con’t): (c) As a final experiment, consider thedeck of 52 cards again, and let A1, A2, A3, and A4 represent theevents of drawing an ace in each of four successive draws. Ifwe replace the card drawn before drawing the next card, thenthe events are statistically independent and it follows that

Page 32: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Relative Frequency & Prob. (Con’t)

Example (Con’t): Suppose now that we do not replace thecards that are drawn. The events then are no longer statisticallyindependent. With reference to the results in the previousexample, we write

Thus we see that not replacing the drawn card reduced ourchances of drawing fours successive aces by a factor of close to10. This significant difference is perhaps larger than might beexpected from intuition.

Page 33: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Random Variables

Random variables often are a source of confusion when firstencountered. This need not be so, as the concept of a randomvariable is in principle quite simple. A random variable, x, is areal-valued function defined on the events of the sample space,S. In words, for each event in S, there is a real number that isthe corresponding value of the random variable. Viewed yetanother way, a random variable maps each event in S onto thereal line. That is it. A simple, straightforward definition.

Page 34: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Random Variables (Con’t)

Part of the confusion often found in connection with randomvariables is the fact that they are functions. The notation also ispartly responsible for the problem. In other words, althoughtypically the notation used to denote a random variable is as wehave shown it here, x, or some other appropriate variable, to bestrictly formal, a random variable should be written as afunction x(·) where the argument is a specific event beingconsidered. However, this is seldom done, and, in ourexperience, trying to be formal by using function notationcomplicates the issue more than the clarity it introduces. Thus,we will opt for the less formal notation, with the warning that itmust be keep clearly in mind that random variables arefunctions.

Page 35: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Random Variables (Con’t)

Example: Consider again the experiment of drawing a singlecard from a standard deck of 52 cards. Suppose that we definethe following events. A: a heart; B: a spade; C: a club; and D: adiamond, so that S = {A, B, C, D}. A random variable is easilydefined by letting x = 1 represent event A, x = 2 represent eventB, and so on.

As a second illustration, consider the experiment of throwing asingle die and observing the value of the up-face. We candefine a random variable as the numerical outcome of theexperiment (i.e., 1 through 6), but there are many otherpossibilities. For example, a binary random variable could bedefined simply by letting x = 0 represent the event that theoutcome of throw is an even number and x = 1 otherwise.

Page 36: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Random Variables (Con’t)

Note the important fact in the examples just given that theprobability of the events have not changed; all a randomvariable does is map events onto the real line.

Page 37: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Random Variables (Con’t)

Thus far we have been concerned with random variables whosevalues are discrete. To handle continuous random variableswe need some additional tools. In the discrete case, theprobabilities of events are numbers between 0 and 1. Whendealing with continuous quantities (which are not denumerable)we can no longer talk about the "probability of an event"because that probability is zero. This is not as unfamiliar as itmay seem. For example, given a continuous function we knowthat the area of the function between two limits a and b is theintegral from a to b of the function. However, the area at apoint is zero because the integral from,say, a to a is zero. Weare dealing with the same concept in the case of continuousrandom variables.

Page 38: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Random Variables (Con’t)

Thus, instead of talking about the probability of a specific value,we talk about the probability that the value of the randomvariable lies in a specified range. In particular, we areinterested in the probability that the random variable is less thanor equal to (or, similarly, greater than or equal to) a specifiedconstant a. We write this as

If this function is given for all values of a (i.e., − ∞ < a < ∞), thenthe values of random variable x have been defined. Function F iscalled the cumulative probability distribution function or simplythe cumulative distribution function (cdf). The shortened termdistribution function also is used.

Page 39: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Random Variables (Con’t)

Observe that the notation we have used makes no distinctionbetween a random variable and the values it assumes. Ifconfusion is likely to arise, we can use more formal notation inwhich we let capital letters denote the random variable andlowercase letters denote its values. For example, the cdf usingthis notation is written as

When confusion is not likely, the cdf often is written simply asF(x). This notation will be used in the following discussionwhen speaking generally about the cdf of a random variable.

Page 40: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Random Variables (Con’t)

Due to the fact that it is a probability, the cdf has the followingproperties:

where x+ = x + ε, with ε being a positive, infinitesimally smallnumber.

Page 41: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Random Variables (Con’t)

The probability density function (pdf) of random variable x isdefined as the derivative of the cdf:

The term density function is commonly used also. The pdfsatisfies the following properties:

Page 42: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Random Variables (Con’t)

The preceding concepts are applicable to discrete randomvariables. In this case, there is a finite no. of events and wetalk about probabilities, rather than probability densityfunctions. Integrals are replaced by summations and,sometimes, the random variables are subscripted. For example,in the case of a discrete variable with N possible values wewould denote the probabilities by P(xi), i=1, 2,…, N.

Page 43: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Random Variables (Con’t)

In Sec. 3.3 of the book we used the notation p(rk), k = 0,1,…, L - 1,to denote the histogram of an image with L possible gray levels, rk,k = 0,1,…, L - 1, where p(rk) is the probability of the kth gray level(random event) occurring. The discrete random variables in thiscase are gray levels. It generally is clear from the context whetherone is working with continuous or discrete random variables, andwhether the use of subscripting is necessary for clarity. Also,uppercase letters (e.g., P) are frequently used to distinguishbetween probabilities and probability density functions (e.g., p)when they are used together in the same discussion.

Page 44: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Random Variables (Con’t)

If a random variable x is transformed by a monotonictransformation function T(x) to produce a new random variable y,the probability density function of y can be obtained fromknowledge of T(x) and the probability density function of x, asfollows:

where the subscripts on the p's are used to denote the fact thatthey are different functions, and the vertical bars signify theabsolute value. A function T(x) is monotonically increasing ifT(x1) < T(x2) for x1 < x2, and monotonically decreasing if T(x1)> T(x2) for x1 < x2. The preceding equation is valid if T(x) is anincreasing or decreasing monotonic function.

Page 45: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Expected Value and Moments

The expected value of a function g(x) of a continuos randomvariable is defined as

If the random variable is discrete the definition becomes

Page 46: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Expected Value & Moments (Con’t)

The expected value is one of the operations used most frequentlywhen working with random variables. For example, the expectedvalue of random variable x is obtained by letting g(x) = x:

when x is continuos and

when x is discrete. The expected value of x is equal to itsaverage (or mean) value, hence the use of the equivalent notationand m.

Page 47: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Expected Value & Moments (Con’t)

The variance of a random variable, denoted by σ², is obtained byletting g(x) = x² which gives

for continuous random variables and

for discrete variables.

Page 48: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Expected Value & Moments (Con’t)

Of particular importance is the variance of random variables thathave been normalized by subtracting their mean. In this case,the variance is

and

for continuous and discrete random variables, respectively. Thesquare root of the variance is called the standard deviation, andis denoted by σ.

Page 49: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Expected Value & Moments (Con’t)

We can continue along this line of thought and define the nthcentral moment of a continuous random variable by letting

and

for discrete variables, where we assume that n ≥ 0. Clearly, µ0=1,µ1=0, and µ2=σ². The term central when referring to momentsindicates that the mean of the random variables has been subtractedout. The moments defined above in which the mean is notsubtracted out sometimes are called moments about the origin.

Page 50: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Expected Value & Moments (Con’t)

In image processing, moments are used for a variety of purposes,including histogram processing, segmentation, and description. Ingeneral, moments are used to characterize the probability densityfunction of a random variable. For example, the second, third, andfourth central moments are intimately related to the shape of theprobability density function of a random variable. The secondcentral moment (the centralized variance) is a measure of spreadof values of a random variable about its mean value, the thirdcentral moment is a measure of skewness (bias to the left or right)of the values of x about the mean value, and the fourth moment isa relative measure of flatness. In general, knowing all themoments of a density specifies that density.

Page 51: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Expected Value & Moments (Con’t)

Example: Consider an experiment consisting of repeatedly firinga rifle at a target, and suppose that we wish to characterize thebehavior of bullet impacts on the target in terms of whether weare shooting high or low.. We divide the target into an upper andlower region by passing a horizontal line through the bull's-eye.The events of interest are the vertical distances from the center ofan impact hole to the horizontal line just described. Distancesabove the line are considered positive and distances below theline are considered negative. The distance is zero when a bullethits the line.

Page 52: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Expected Value & Moments (Con’t)

In this case, we define a random variable directly as the value ofthe distances in our sample set. Computing the mean of therandom variable indicates whether, on average, we are shootinghigh or low. If the mean is zero, we know that the average of ourshots are on the line. However, the mean does not tell us how farour shots deviated from the horizontal. The variance (or standarddeviation) will give us an idea of the spread of the shots. A smallvariance indicates a tight grouping (with respect to the mean, andin the vertical position); a large variance indicates the opposite.Finally, a third moment of zero would tell us that the spread of theshots is symmetric about the mean value, a positive third momentwould indicate a high bias, and a negative third moment wouldtell us that we are shooting low more than we are shooting highwith respect to the mean location.

Page 53: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

The Gaussian Probability Density Function

Because of its importance, we will focus in this tutorial on theGaussian probability density function to illustrate many of thepreceding concepts, and also as the basis for generalization tomore than one random variable. The reader is referred to Section5.2.2 of the book for examples of other density functions.

A random variable is called Gaussian if it has a probabilitydensity of the form

where m and σ are as defined in the previous section. The termnormal also is used to refer to the Gaussian density. A plot andproperties of this density function are given in Section 5.2.2 ofthe book.

Page 54: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

The Gaussian PDF (Con’t)

The cumulative distribution function corresponding to theGaussian density is

which, as before, we interpret as the probability that the randomvariable lies between minus infinite and an arbitrary value x.This integral has no known closed-form solution, and it must besolved by numerical or other approximation methods. Extensivetables exist for the Gaussian cdf.

Page 55: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Several Random Variables

In the previous example, we used a single random variable todescribe the behavior of rifle shots with respect to a horizontalline passing through the bull's-eye in the target. Although this isuseful information, it certainly leaves a lot to be desired in termsof telling us how well we are shooting with respect to the centerof the target. In order to do this we need two random variablesthat will map our events onto the xy-plane. It is not difficult tosee how if we wanted to describe events in 3-D space we wouldneed three random variables. In general, we consider in thissection the case of n random variables, which we denote by x1,x2,…, xn (the use of n here is not related to our use of the samesymbol to denote the nth moment of a random variable).

Page 56: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Several Random Variables (Con’t)

It is convenient to use vector notation when dealing with severalrandom variables. Thus, we represent a vector random variable xas

Then, for example, the cumulative distribution functionintroduced earlier becomes

Page 57: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Several Random Variables (Con’t)

when using vectors. As before, when confusion is not likely, thecdf of a random variable vector often is written simply as F(x).This notation will be used in the following discussion whenspeaking generally about the cdf of a random variable vector.

As in the single variable case, the probability density function ofa random variable vector is defined in terms of derivatives of thecdf; that is,

Page 58: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Several Random Variables (Con’t)

The expected value of a function of x is defined basically asbefore:

Page 59: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Several Random Variables (Con’t)

Cases dealing with expectation operations involving pairs ofelements of x are particularly important. For example, thejoint moment (about the origin) of order kq between variablesxi and xj

Page 60: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Several Random Variables (Con’t)

When working with any two random variables (any twoelements of x) it is common practice to simplify the notation byusing x and y to denote the random variables. In this case thejoint moment just defined becomes

It is easy to see that ηk0 is the kth moment of x and η0q is theqth moment of y, as defined earlier.

Page 61: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Several Random Variables (Con’t)

The moment η11 = E[xy] is called the correlation of x and y. Asdiscussed in Chapters 4 and 12 of the book, correlation is animportant concept in image processing. In fact, it is important inmost areas of signal processing, where typically it is given aspecial symbol, such as Rxy:

Page 62: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Several Random Variables (Con’t)

If the condition

holds, then the two random variables are said to be uncorrelated.From our earlier discussion, we know that if x and y arestatistically independent, then p(x, y) = p(x)p(y), in which case wewrite

Thus, we see that if two random variables are statisticallyindependent then they are also uncorrelated. The converse ofthis statement is not true in general.

Page 63: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Several Random Variables (Con’t)

The joint central moment of order kq involving randomvariables x and y is defined as

where mx = E[x] and my = E[y] are the means of x and y, asdefined earlier. We note that

are the variances of x and y, respectively.

and

Page 64: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Several Random Variables (Con’t)

The moment µ11

is called the covariance of x and y. As in the case ofcorrelation, the covariance is an important concept, usuallygiven a special symbol such as Cxy.

Page 65: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Several Random Variables (Con’t)

By direct expansion of the terms inside the expected valuebrackets, and recalling the mx = E[x] and my = E[y], it isstraightforward to show that

From our discussion on correlation, we see that the covariance iszero if the random variables are either uncorrelated or statisticallyindependent. This is an important result worth remembering.

Page 66: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Several Random Variables (Con’t)

If we divide the covariance by the square root of the product ofthe variances we obtain

The quantity γ is called the correlation coefficient of randomvariables x and y. It can be shown that γ is in the range −1 ≤ γ ≤ 1(see Problem 12.5). As discussed in Section 12.2.1, thecorrelation coefficient is used in image processing for matching.

Page 67: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

The Multivariate Gaussian Density

As an illustration of a probability density function of more thanone random variable, we consider the multivariate Gaussianprobability density function, defined as

where n is the dimensionality (number of components) of therandom vector x, C is the covariance matrix (to be definedbelow), |C| is the determinant of matrix C, m is the meanvector (also to be defined below) and T indicates transposition(see the review of matrices and vectors).

Page 68: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

The Multivariate Gaussian Density (Con’t)

The mean vector is defined as

and the covariance matrix is defined as

Page 69: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

The Multivariate Gaussian Density (Con’t)

The element of C are the covariances of the elements of x, suchthat

where, for example, xi is the ith component of x and mi is theith component of m.

Page 70: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

The Multivariate Gaussian Density (Con’t)

Covariance matrices are real and symmetric (see the review ofmatrices and vectors). The elements along the main diagonal of Care the variances of the elements x, such that cii= σxi². When allthe elements of x are uncorrelated or statistically independent, cij =0, and the covariance matrix becomes a diagonal matrix. If all thevariances are equal, then the covariance matrix becomesproportional to the identity matrix, with the constant ofproportionality being the variance of the elements of x.

Page 71: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

The Multivariate Gaussian Density (Con’t)

Example: Consider the following bivariate (n = 2) Gaussianprobability density function

with

and

Page 72: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

The Multivariate Gaussian Density (Con’t)

where, because C is known to be symmetric, c12 = c21. Aschematic diagram of this density is shown in Part (a) of thefollowing figure. Part (b) is a horizontal slice of Part (a). From thereview of vectors and matrices, we know that the main directionsof data spread are in the directions of the eigenvectors of C.Furthermore, if the variables are uncorrelated or statisticallyindependent, the covariance matrix will be diagonal and theeigenvectors will be in the same direction as the coordinate axes x1and x2 (and the ellipse shown would be oriented along the x1 - andx2-axis). If, the variances along the main diagonal are equal, thedensity would be symmetrical in all directions (in the form of abell) and Part (b) would be a circle. Note in Parts (a) and (b) thatthe density is centered at the mean values (m1,m2).

Page 73: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

The Multivariate Gaussian Density (Con’t)

Page 74: review of probability - Scientific Computing and …Review of Probability Objective To provide background material in support of topics in Digital Image Processing that are based on

Digital Image Processing, 3rd ed.

www.ImageProcessingPlace.com

© 1992–2008 R. C. Gonzalez & R. E. Woods

Gonzalez & WoodsReview of Probability

Linear Transformations of Random Variables

As discussed in the Review of Matrices and Vectors, a lineartransformation of a vector x to produce a vector y is of the formy = Ax. Of particular importance in our work is the case whenthe rows of A are the eigenvectors of the covariance matrix.Because C is real and symmetric, we know from the discussionin the Review of Matrices and Vectors that it is always possibleto find n orthonormal eigenvectors from which to form A. Theimplications of this are discussed in considerable detail at theend of the Review of Matrices and Vectors, which werecommend should be read again as a conclusion to the presentdiscussion.