5 Random Var PDF
5 Random Var PDF
5 Random Var PDF
9.07
2/19/2004
xlabel(text)
ylabel(text)
title(text)
MATLAB:
MATLAB
x = rand(5,10000);
coinflip = x>0.5;
MATLAB
plot(hist(data)) vs.
[n,x]=hist(data); plot(x,n)
Random Variables
2 = (xi-)2P(xi) E((x-)2)
special cases
p
x
Etc.
Random variables
r.v.
variables
E(x) =
E(x-)2 = E(x2-2x+2) = 2
= E(x2-2x+2) = 2 = ()2
variables
E(2x) = 2E(x) = 2 =
E(-2x) = 2E(x) = -2 =
apply a transformation?
variables
P(-0.75<z<0.75) =
0.5467
P(z<-0.75 or
z>0.75) = 1-0.5467
0.45
Thats our answer.
What %
-.75
0.70
0.75
0.80
0 .75
Height
31.23
30.11
28.97
Area
51.61
54.67
57.63
5%
z = ?
percentile point
90%
5%
5%
z
1.65
Height Area
10.23 90.11
Normal distributions
Non-normal distributions
Non-normal distributions
median=Q1
= 25th percentile
median=Q3
= 75th percentile
percentiles?
percentiles?
first approximation)
(x = the data)
y = sort(x);
N = length(x);
% how many data points there are
TenthPerc = y(0.10*N);
normal?
data
For each datum, what % of the data is
below this value whats its percentile?
If this were a normal distribution, what z
would correspond to that percentile?
Compare the actual data values to those
predicted (from the percentiles) if it were
a standard normal (z) distribution.
z=?
data
data~N(, )
-1 0 1
Basic idea:
40
y axis
20
-20
-40
-3
-2
-1
0
z-score
40
y axis
30
20
10
-3
-2
-1
0
z-score
Non-linear plots
100
Dollars Spent
80
60
40
20
0
-3
-2
-1
0
z-score
600
500
400
300
200
100
0
-3
-2
-1
0
z-score
140
IQ Score
120
100
80
60
-3
-2
-1
z-score
Figure by MIT OCW.
Granularity
Distance (thousandths
of an inch)
80
60
40
20
-3
-2
-1
0
z-score
Example
P(4H, 2T) =
(# events of this type) x (0.5)4 (1-0.5)2
N
N!
=
k k!(N k )!
N! = N factorial = N(N-1)(N-2)(1)
= factorial(N) in MATLAB
0! = 1
Binomial coefficient
Example
P(4 H in 6 tosses) =
N
k
N k
p
(1
p
)
=
(0.5) 4 (0.5) 2
6
5 4 3
2 1 1 15
3
2 1 2
1 64 64
10 pairs of kangaroos
Half of them get vitamins
10 races (vitamin vs. no vitamin)
How do we decide?
Roo races
Roo races
p. A-71)
Roo races
random variable
= np
2 = npq
q = 1-p
more times?
Probability Histogram
(3 coins)
0.4
0.35
0.3
0.25
0.2
0.15
0.1
0.05
0
0
1
Number of Heads
0.4
Probability Histogram
(4 coins)
0.35
0.3
0.25
0.2
0.15
0.1
0.05
0
2
Number of Heads
Probability Histogram
(10 coins)
0.3
0.25
0.2
0.15
0.1
0.05
Number of Heads
10
Binomial Distribution
0.7
p = .05
n = 10
0.6
0.5
p(x)
0.4
0.3
0.2
0.1
0
0
Number of Successes
Binomial Distribution
0.3
p = .05
n = 50
0.25
0.2
0.15
0.1
0.05
0
0
Number of Successes
Binomial Distribution
0.2
p = .05
n = 100
0.18
0.16
0.14
0.12
0.1
0.08
0.06
0.04
0.02
0
0
Number of Successes
10
Normal Approximation
0.5
The further p is from .5, the larger n you need
Rule of thumb: use when np10 and nq10
Normal Approximation
25 coin flips
Normal Approximation
Normal Approximation of
Binomial Distribution
0.18
0.16
0.14
0.12
0.1
0.08
0.06
0.04
0.02
10
11
12
13
14
15
Number of Successes
16
17
18
19
20
21
22
23
24
25
Continuity Correction
Continuity Correction
0.18
0.16
0.14
0.12
0.1
0.08
0.06
0.04
0.02
0
0
10
11
12
13
14
15
Number of Successes
16
17
18
19
20
21
22
23
24
25
In MATLAB:
x = rand(5,10000);
coinflip = x>0.5;
% 1 = heads
y = sum(x);
% number of heads
# of coin
flips =
# trials = 5
# of coin
flips =
# trials = 5