You are on page 1of 41

# • The event L of obtaining the number 7 is

L occurs if any of the outcomes in L occurs

# Tails

7

>> n = 10;
>> outcomes = randi([1 2],1,n)
outcomes =
2
1
2
1
2
2
2
1
1
1
>> heads = outcomes(outcomes == 1)
1
1
1
1
1
m =
5
>> f = m/n
f =
0.5

# 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
>> n = 10;
>> outcomes = randi([1 2],1,n)
outcomes =
2
1
2
1
2
2
2
1
1
1
>> outcomes(outcomes == 2) = 0
outcomes =
0
1
0
1
0
0
0
1
1
1
>> f = cumsum(outcomes)./(1:n)
f =
Columns 1 through 8
0 0.5 0.33333 0.5 0.4 0.33333 0.28571 0.375
Columns 9 through 10
0.44444
0.5
>> plot(f)
n = 100
n = 10
n = 1,000,000
n = 1,000

12

S
A
B

S
A
B

A

S
B

# .

the probability that,
after throwing a dice,
X will be equal to x i

18

# the probability distribution function satisfies:

>> x =[2 3 4 5 6 7 8 9 10 11 12];
>> p =[1 2 3 4 5 6 5
4 3 2 1] / 36;
>> bar(x,p)
>> xlabel('x_i')
>> ylabel('p(x_i)')

# • The cumulative distribution function (CDF) for a discrete random variable X is defined as

>> x =[2 3 4 5 6 7 8 9 10 11 12];
>> p =[1 2 3 4 5 6 5
4 3 2 1] / 36;
>> bar(x,cumsum(p))
>> xlabel('x_i')
>> ylabel('F(x_i)')

probability
density function

# • may assume any numerical value in an interval • continuous distribution function

cumulative distribution function
probability density function

27

=area
a
b

# 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

# 50th percentile correlation coefficient

Matlab statistics toolbox:
normpdf, normcdf, …

# 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
>>

# Generates Uniformly distributed random numbers between 0 and 1.

>> x = rand(1,1e6);
>> histogram(x)