LECTURE 22
Statistics
– Probability – Continuous Random Variable – Distributions – More on Histograms – More on Random Numbers – Matlab Functions
Probability relates to events, which are phenomena that may be observed either to happen or not to happen.
Examples: flipping a coin, rolling dice, …
Probability of an event is a numerical measure of the likelihood of its occurrence
Experiment:
A situation whose outcome depends on chance;
example: throwing of a die
Sample Space S:
The set of all possible outcomes of an experiment;
example: S =
Event:
A subsets of the sample space S; example: observing an even number of dots
Experiment: throwing a pair of dice (one red and one blue) • The sample space has 36 outcomes:
S =
• The event L of obtaining the number 7 is
L occurs if any of the outcomes in L occurs
Probability:
• A number between 0 and 1, inclusive, that indicates how likely an event is to occur
– An event with probability of 0 is a null event
(e.g., there will be two moons tonight)
– An event with probability of 1 is a sure event
(e.g., the sun will set tonight)
• Probability of event A is denoted as P(A) • The closer P(A) to 1, the more likely is A to occur
An experiment is repeated n times under essentially identical conditions and event A occurred m times
As n grows large
relative frequency of event A
probability of event A
Experiment: flipping a fair coin
Two Outcomes (and Events):
Heads
Tails
Generates a uniformly distributed random number between n and m
size of x
>> x = randi([1 3],3,5)
x =
2
2
1
3
3
2
2
1
3
1
3
3
2
1
3
Union of events A and B
set of outcomes that are in A or B or both
Intersection of events A and B
set of outcomes in both A and B
Complement of an event A
S
If A and B are mutually exclusive events
A
If A and B are independent events
Two Outcomes (and Events):
Fair coin:
P(Heads) = P(Tails) = P
Tails = sure event
Random Variable is a variable
• which will have value as a result of a test but the value is unknown • whose value is subject to variations due to chance (hence, randomness) • it can take on a set of possible different values, each with an associated probability
Discrete Random Variable
• can have only values from a countable set
Continuous Random Variable
• may assume any numerical value in an interval
The sample space has 36 outcomes:
S =
X is a discrete random variable associated with events, e.g., observing sums of the dice dots:
X = {x _{i} } = {x _{1} , x _{2} , …, x _{1}_{1} } = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
X is a discrete random variable associated with events e.g., sums of the dice dots:
X = {x _{i} } = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
Each event has a probability of its occurrence, for example,
P(X = x _{1} ) = p _{1} P(X = x _{2} ) = p _{2} .
.
.
the probability that,
after throwing a dice,
X will be equal to x i
i.e., P(x) = {p _{i} } = {p _{1} , p _{2} , …, p _{1}_{1} }
discrete distribution function
The sample space has 36 outcomes:
S =
Fair dice: outcomes are equiprobable—i.e., all outcomes have th e same probability, p Mutually exclusive outcomes: their union is a sure event
p = 1/36
probability of each outcome
Experiment: throwing a pair of dice (one red and one blue)
S =
The probability of throwing, say, a red 1 and a blue 5 is
P(1 5 ) = P(1) P(5) = 1/6 1/6 = 1/36
The probability of 1 out of 36 possible outcomes
S =
probability of each outcome
1/36
X = m when the throw of dice results in the number m
we now estimate:
_{P}_{(}_{m}_{)} _{=} _{P}_{(}_{X} _{=} _{m}_{)}
• random variable X takes values
• probability distribution function takes the corresponding values:
the probability distribution function satisfies:
• The cumulative distribution function (CDF) for a discrete random variable X is defined as
Discrete Random Variable
• can have only values from a countable set • discrete distribution function
Continuous Random Variable
probability
density function
• may assume any numerical value in an interval • continuous distribution function
A histogram is a plot of frequency of occurrence of data values versus the values themselves.
>> histogram(X)
Aggregates vector data X into 10 evenly spaced bins between
min(X) and max(X)
Returns handle
>> h = histogram(X,n)
handle
into n bins
Probability Density Function (pdf) –distribution of random variable X
MATLAB STATISTICAL FUNCTIONS
_{m}_{e}_{a}_{n}
var
average value
variance
std
median
corrcoef
standard deviation
50th percentile correlation coefficient
Matlab statistics toolbox:
normpdf, normcdf, …
mean standard deviation
mean standard deviation
Generates Normal (Gaussian) random numbers with = 0 and = 1
>> x = randn(1,1e6);
>> h = histogram(x,100)
h =
Histogram with properties:
Data: [1×1000000 double]
Values: [1×100 double]
NumBins: 100
BinEdges: [1×101 double]
BinWidth: 0.1
BinLimits: [5.31 4.69]
Normalization: 'count'
FaceColor: 'auto'
EdgeColor: [0 0 0]
Show all properties
>>
Probability interpretation:





















The error function erf(x) is twice the integral from 0 to x of the Gaussian distribution with 0 mean and 1/2 variance
The complementary error function erfc(x) is
Generates Uniformly distributed random numbers between 0 and 1.
>> x = rand(1,1e6);
>> histogram(x)
MATLAB FUNCTIONS
rand, randi, randn randperm histogram
bar, barh, bar3, bar3h pie, pie3 stairs, stem, stem3
pcolor
try >>pcolor(rand(10))
• Probability is a number between 0 and 1, inclusive, that indicates how likely a chance event is to occur.
• Basic probability concepts
– Sample space, outcome, event
• Random variables
– Discrete and continuous
• Distribution functions
– Discrete, cumulative
• Properties of distribution functions
– mean, variance, standard deviation
• Converting histograms into PDF • Normal and Uniform distributions • Matlab functions rand, randn, randi, cumsum,…