1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability...

109
Data Structures & Algorithms Week1
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    220
  • download

    1

Transcript of 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability...

Page 1: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

1

ECON 240AECON 240A

Power 5Power 5

Page 2: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

2

Last Tuesday & Lab TwoLast Tuesday & Lab Two

ProbabilityProbability Discrete Binomial Probability Discrete Binomial Probability

DistributionDistribution

Page 3: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

3

The Normal DistributionThe Normal Distribution

Page 4: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

4

OutlineOutline

The cumulative distribution function, The cumulative distribution function, or sigmoid (S-shaped curve)or sigmoid (S-shaped curve)

The normal distribution as an The normal distribution as an approximation to the binomialapproximation to the binomial

The standardized normal variable, zThe standardized normal variable, z sample meanssample means The distribution of the sample mean: The distribution of the sample mean:

the normal distributionthe normal distribution

Page 5: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Binomial Distribution

Five Flips of a Fair Coindensity cumulative

k n p0 5 0.03125 0.031251 5 0.15625 0.18752 5 0.3125 0.53 5 0.3125 0.81254 5 0.15625 0.968755 5 0.03125 1

Page 6: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

6

Probability Density Probability Density FunctionFunction

Five Flips of a Fair Coin

0

0.05

0.1

0.15

0.2

0.25

0.3

0.35

0 1 2 3 4 5

Number of Heads

Pro

bab

ilit

y

Page 7: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

7

Cumulative Distribution Cumulative Distribution FunctionFunction

Five Flips of a Fair Coin

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

0 1 2 3 4 5

Number of Heads

Pro

ba

bil

ity

Page 8: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

8

Cumulative Distribution Cumulative Distribution FunctionFunction

The probability of getting two or less The probability of getting two or less heads in five flips is 0.5heads in five flips is 0.5• can use the cumulative distribution functioncan use the cumulative distribution function• can use the probability density function and can use the probability density function and

add the probabilities for 0, 1, and 2 headsadd the probabilities for 0, 1, and 2 heads the probability of getting two heads or the probability of getting two heads or

three heads isthree heads is• can add the probabilities for 2 heads and can add the probabilities for 2 heads and

three heads from the probability density three heads from the probability density function function

Page 9: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

9

Cumulative Distribution Cumulative Distribution FunctionFunction

Five Flips of a Fair Coin

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

0 1 2 3 4 5

Number of Heads

Pro

ba

bil

ity

Page 10: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Binomial Distribution

Five Flips of a Fair Coindensity cumulative

k n p0 5 0.03125 0.031251 5 0.15625 0.18752 5 0.3125 0.53 5 0.3125 0.81254 5 0.15625 0.968755 5 0.03125 1

Page 11: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

11

Cumulative Distribution Cumulative Distribution FunctionFunction

the probability of getting two heads or the probability of getting two heads or three heads is:three heads is:• can add the probabilities for 2 heads and can add the probabilities for 2 heads and

three heads from the probability density three heads from the probability density function function

• can use the probability of getting up to 3 can use the probability of getting up to 3 heads, P(3 or less heads) from the heads, P(3 or less heads) from the cumulative distribution function (CDF) and cumulative distribution function (CDF) and subtract the probability of getting up to subtract the probability of getting up to one head P(1 or less heads]one head P(1 or less heads]

Page 12: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

12

Probability Density Probability Density FunctionFunction

Five Flips of a Fair Coin

0

0.05

0.1

0.15

0.2

0.25

0.3

0.35

0 1 2 3 4 5

Number of Heads

Pro

bab

ilit

y

Page 13: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Binomial Distribution

Five Flips of a Fair Coindensity cumulative

k n p0 5 0.03125 0.031251 5 0.15625 0.18752 5 0.3125 0.53 5 0.3125 0.81254 5 0.15625 0.968755 5 0.03125 1

Page 14: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Binomial Distribution

Five Flips of a Fair Coindensity cumulative

k n p0 5 0.03125 0.031251 5 0.15625 0.18752 5 0.3125 0.53 5 0.3125 0.81254 5 0.15625 0.968755 5 0.03125 1

Page 15: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

15

Cumulative Distribution Cumulative Distribution FunctionFunction

Five Flips of a Fair Coin

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

0 1 2 3 4 5

Number of Heads

Pro

ba

bil

ity

]3[ hp

]1[ hp

Page 16: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

16

For the Binomial For the Binomial DistributionDistribution

Can use a computer as we did in Can use a computer as we did in Lab TwoLab Two

Can use Tables for the cumulative Can use Tables for the cumulative distribution function of the distribution function of the binomial such as Table 1 in the binomial such as Table 1 in the text in Appendix B, p. B-1text in Appendix B, p. B-1• need a table for each p and n.need a table for each p and n.

Page 17: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

17

Page 18: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

18

Normal Approximation to Normal Approximation to the binomialthe binomial

Fortunately, for large samples, we Fortunately, for large samples, we can approximate the binomial with can approximate the binomial with the normal distribution, as we saw the normal distribution, as we saw in Lab Twoin Lab Two

Page 19: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Forty Tosses of a Fair Coin

0

0.02

0.04

0.06

0.08

0.1

0.12

0.14

0 3 6 9 12 15 18 21 24 27 30 33 36 39

Number of Heads

Pro

bab

ilty

Binomial Probability Density Function

Page 20: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Forty Tosses of a Fair Coin

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

0 3 6 9 12 15 18 21 24 27 30 33 36 39

Number of Heads

Pro

bab

ility

Binomial Cumulative Distribution Function

Page 21: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

21

The Normal DistributionThe Normal Distribution

What would the normal density What would the normal density function look like if it had the same function look like if it had the same expected value and the same expected value and the same variance as this binomial variance as this binomial distributiondistribution• from Power 4, E(h) = n*p =40*1/2=20from Power 4, E(h) = n*p =40*1/2=20• from Power 4, VAR[h] = n*p*(1-p) = from Power 4, VAR[h] = n*p*(1-p) =

40*1/2*1/2 =1040*1/2*1/2 =10

Page 22: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Normal Density Function, Mean 20, Variance 10

0

0.02

0.04

0.06

0.08

0.1

0.12

0.14

0 10 20 30 40 50

Number of Heads

Den

sity

Page 23: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Comparing the Normal Density with the Binomial Probability Distribution

0

0.02

0.04

0.06

0.08

0.1

0.12

0.14

0 3 6 9 12 15 18 21 24 27 30 33 36 39

Number of Heads

Den

sity

binomial

normal

Page 24: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Comparing the Binomial and Normal Distribution Functions

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

0 3 6 9 12 15 18 21 24 27 30 33 36 39

Number of Heads

Pro

bab

ilit

y

binomial

normal

Page 25: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Comparing the Binomial and Normal (Mean = 19.5) Cumulative Distribution Functions

0

0.2

0.4

0.6

0.8

1

1.20 3 6 9 12 15 18 21 24 27 30 33 36 39

Number of Heads

Pro

bab

ilit

y

binomial

normal

Page 26: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Normal Approximation to Normal Approximation to the Binomial: De Moivrethe Binomial: De Moivre

P(a k b) P[(a – ½ - np)/ )1(pnp z [(b + ½ - np)/ )1(pnp]

This is the probability that the number of heads will fall in theinterval a through b, as determined by the normal cumulative distribution function, using a mean of n*p, and a standard deviation equal to the square root of n*p*(1-p), i.e. the square root of thevariance of the binomial distribution. The parameter 1/2 is a continuity correction since we are approximating a discrete functionwith a continuous one, and was the motivation of using mean 19.5instead of mean 20 in the previous slide. Visually, this seemed to be a better approximation than using a mean of 20.

Page 27: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

27

Guidelines for using the Guidelines for using the normal approximationnormal approximation

n*p>=5n*p>=5 n*(1-p)>=5n*(1-p)>=5

Page 28: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

28

The Standardized Normal The Standardized Normal VariateVariate

Z~N(0, 1.0]Z~N(0, 1.0] E[z} = 0E[z} = 0 VAR[Z] = 1VAR[Z] = 1

Page 29: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Density Function for the Standardized Normal Variate

0

0.05

0.1

0.15

0.2

0.25

0.3

0.35

0.4

0.45

-5 -4 -3 -2 -1 0 1 2 3 4 5

Standard Deviations

Den

sity

2]1/)0[(2/1*]2/1[)( zezf

Page 30: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Cumulative Distribution Function for a Standardized Normal Variate

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

-5 -4 -3 -2 -1 0 1 2 3 4 5

Standrd Deviations

Pro

ba

bil

ty

Page 31: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Normal Variate xNormal Variate x

– E(z) = 0E(z) = 0– VAR(z) = 1VAR(z) = 1

),(~ 2Nx

)(xE

2][ xVAR

xorzxz *,/)(

Page 32: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Normal Density Function, Mean 20, Variance 10

0

0.02

0.04

0.06

0.08

0.1

0.12

0.14

0 10 20 30 40 50

Number of Heads

Den

sity

2]/)[(2/1*)2/1()( xexf

Page 33: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Normal Cumulative Distribution Function, Mean=20, Variance = 10

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

0 10 20 30 40 50

Number of Heads

Pro

ba

bil

ity

b

dxxfbF )()(

b

Page 34: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Normal Density Function, Mean 20, Variance 10

0

0.02

0.04

0.06

0.08

0.1

0.12

0.14

0 10 20 30 40 50

Number of Heads

Den

sity

2]/)[(2/1*)2/1()( xexf

b

Page 35: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

35

For the Normal For the Normal DistributionDistribution

Can use a computer as we did in Can use a computer as we did in Lab TwoLab Two

Can use Tables for the cumulative Can use Tables for the cumulative distribution function of the normal distribution function of the normal such as Table 3 in the text in such as Table 3 in the text in Appendix B, p. B-8Appendix B, p. B-8• need only one table for the need only one table for the

standardized normal variate Z.standardized normal variate Z.

Page 36: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

36

Page 37: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

37

Sample MeansSample Means

Page 38: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

38

Sample Mean ExampleSample Mean Example

Rate of return on UC Stock Index FundRate of return on UC Stock Index Fund return equals capital gains or losses return equals capital gains or losses

plus dividendsplus dividends monthly rate of return equals price monthly rate of return equals price

this month minus price last month, this month minus price last month, plus dividends, all divided by the plus dividends, all divided by the price last monthprice last month

r(t) ={ p(t) -p(t-1) + d(t)}/p(t-1)r(t) ={ p(t) -p(t-1) + d(t)}/p(t-1)

Page 39: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

39

Rate of Return UC Stock Rate of Return UC Stock Index Fund,Index Fund, http://atyourservice.ucop.http://atyourservice.ucop.edu/edu/

Date Rate Sept 2003 -0.29 Oct 2003 5.84 Nov 2003 1.40 Dec 2003 5.01 Jan 2004 1.95 Feb 2004 1.40 March 2004 -0.85

Page 40: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

40

Table Cont.Table Cont.

Date Rate

April 2004 -2.19

May 2004 1.36

June 2004 1.02

July 2004 -3.51

Aug 2004 0.45

Page 41: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Rate of Return UC Stock Index Fund

-4

-2

0

2

4

6

8

Sep-03 Oct-03 Nov-03

Dec-03 J an-04 Feb-04 Mar-04 Apr-04 May-04

J un-04 J ul-04 Aug-04

Date

Page 42: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

42

Rate of Return UC Stock Rate of Return UC Stock Index Fund,Index Fund, http://atyourservice.ucop.http://atyourservice.ucop.edu/edu/

Date RateSept 2002 -3.51Oct 2002 7.84Nov 2002 5.13Dec 2002 -5.24Jan 2003 -2.51Feb 2003 -1.66March 2003 0.61

Page 43: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

43

Table Cont.Table Cont.

Date Rate

April 2003 8.43

May 2003 5.55

June 2003 1.34

July 2003 2.67

Aug 2003 2.26

Page 44: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Rate of Return UC Stock Index Fund

-6

-4

-2

0

2

4

6

8

10

Jul-02 Sep-02

Oct-02 Dec-02

Jan-03 Mar-03

May-03

Jun-03 Aug-03

Oct-03

Date

Rat

e

Page 45: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

45

Data ConsiderationsData Considerations

Time series data for monthly rate of Time series data for monthly rate of returnreturn

since we are using the fractional change since we are using the fractional change in price (ignoring dividends) times 100 in price (ignoring dividends) times 100 to convert to %, the use of changes to convert to %, the use of changes approximately makes the observations approximately makes the observations independent of one anotherindependent of one another

in contrast, if we used price instead of in contrast, if we used price instead of price changes, the observations would price changes, the observations would be correlated, not independentbe correlated, not independent

Page 46: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Cont.

assume a fixed target, i.e. the central tendency of the rate is fixed, not time varying

Assume the rate has some distribution, f, other than normal: ri

= sample mean:

),( 2f

74.112/)(03'

02'

Aug

Septi

irr

Last 12 months, mean = 1.05

Page 47: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Rate of Return UC Stock Index Fund

-6

-4

-2

0

2

4

6

8

10

Jul-02 Sep-02

Oct-02 Dec-02

Jan-03 Mar-03

May-03

Jun-03 Aug-03

Oct-03

Date

Rat

e

1.74

Page 48: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

48

What are the properties of What are the properties of this sample mean?this sample mean?

Page 49: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

n

i

n

i

ixEcixfixcixfixccxE11

)]([*)]([*)(*)]([*)(*][

Note: Expected value of a constant, c, times a random variable, x(i), where i indexes the observation

Note: Variance of a constant times a random variable

VAR[c*x] = E{cx - E[c*x]}2 = E{c*[x-Ex]}2 =E{c2[x -Ex]2 } = c2 *E[x-Ex]2 = c2 *VARx

Last Time

Page 50: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Properties of

Expected value:

Variance

12

1

12

1

12*)12/1()]([12/1}12/)]([{)(i i

irEirErE

12

1

12

1

2222 12/12*)12/1()]([)12/1(}12/)({)(i i

irVARirVARrVAR

),(~)(,, 2firwherer

Page 51: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

51

Central Limit TheoremCentral Limit Theorem

As the sample size grows, no As the sample size grows, no matter what the distribution, f, of matter what the distribution, f, of the rate of return, r, the the rate of return, r, the distribution of the sample mean distribution of the sample mean approaches normalityapproaches normality

Page 52: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

An interval for the sample mean

]}/)[(]/){[()( nbrnapbrap

Page 53: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

53

The rate of return, rThe rate of return, ri i , could be distributed as uniform

f[r(i)]

r(i)

Page 54: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

54

And yet for a large sample, And yet for a large sample, the sample mean will be the sample mean will be distributed as normaldistributed as normal

Cumulative Distribution Function for a Standardized Normal Variate

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

-5 -4 -3 -2 -1 0 1 2 3 4 5

Standrd Deviations

Pro

ba

bilt

y

a

b

Page 55: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

55

Bottom LineBottom Line

We can use the normal distribution We can use the normal distribution to calculate probability statements to calculate probability statements about sample meansabout sample means

Page 56: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

An interval for the sample mean

]}/)[(]/){[()( nbrnapbrap

calculate

chooseinfer

?, Assume we know,or use sample standard deviation, s

Page 57: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

Sample Standard Deviation

If we use the sample standard deviation, s, then for small samples, approximately less then 100 observations, we use Student’s t distribution instead of the normal

n

i

nrirs1

2 )1/(])([

Page 58: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

58

Text p.253Normal compared to t

t-distribution

t distributionas smple size grows

Page 59: 1 ECON 240A Power 5. 2 Last Tuesday & Lab Two b Probability b Discrete Binomial Probability Distribution.

59

Appendix BTable 4p. B-9