physics 114: lecture 9 probability density functions dale e. gary njit physics department

15
Physics 114: Lecture 9 Probability Density Functions Dale E. Gary NJIT Physics Department

Upload: angelina-park

Post on 16-Dec-2015

232 views

Category:

Documents


7 download

TRANSCRIPT

Page 1: Physics 114: Lecture 9 Probability Density Functions Dale E. Gary NJIT Physics Department

Physics 114: Lecture 9 Probability Density

Functions

Dale E. Gary

NJIT Physics Department

Page 2: Physics 114: Lecture 9 Probability Density Functions Dale E. Gary NJIT Physics Department

February 12, 2010

Binomial Distribution If you raise the sum of two variables to a power, you get:

Writing only the coefficients, you begin to see a pattern:

0

1

2 2 2

3 3 2 2 3

4 4 3 2 2 3 4

( ) 1

( )

( ) 2

( ) 3 3

( ) 4 6 4

a b

a b a b

a b a ab b

a b a a b ab b

a b a a b a b ab b

1 1 1 1 2 1 1 3 3 1 1 4 6 4 1

Page 3: Physics 114: Lecture 9 Probability Density Functions Dale E. Gary NJIT Physics Department

February 12, 2010

Binomial Distribution Remarkably, this pattern is also the one that governs the

possibilities of tossing n coins:

With 3 coins, there are 8 ways for them to land, as shown above. In general, there are 2n possible ways for n coins to land. How many permutations are there for a given row, above, e.g. how

many permutations for getting 1 head and 2 tails? Obviously, 3. How many permutation for x heads and n x tails, for general n and

x?

1 1 1 1 2 1 1 3 3 1 1 4 6 4 1

n 2n

0 11 22 43 84 16

Number of combinations in each row: !( , )

!( )!

nnC n x

xx n x

(n choose x)

Page 4: Physics 114: Lecture 9 Probability Density Functions Dale E. Gary NJIT Physics Department

February 12, 2010

Probability With fair coins, tossing a coin will result in equal chance of 50%, or ½, of its ending up heads. Let us

call this probability p. Obviously, the probability of tossing a tails, q, is q = (1 p). With 3 coins, the probability of getting any single one of the combinations is 1/2n = 1/8th, (since there

are 8 combinations, and each is equally probable). This comes from (½) (½) (½), or the product of each probability p = ½ to get a heads.

If we want to know the probability of getting, say 1 heads and 2 tails, we just need to multiply the probability of any combination (1/8th) by the number of ways of getting 1 heads and 2 tails, i.e. 3, for a total probability of 3/8.

To be really general, say the coins were not fair, so p ≠ q. Then the probability to get heads, tails, tails would be (p)(q)(q) = p1q2.

Finally the probability P(x; n, p) of getting x heads given n coins each of which has probability p, is

With 3 coins, there are 8 ways for them to land, as shown above. In general, there are 2n possible ways for n coins to land. How many permutations are there for a given row, above, e.g. how many permutations for getting 1

head and 2 tails? Obviously, 3. How many permutation for x heads and n x tails, for general n and x?

!( ; , ) (1 ) .

!( )!x n x x n xn n

P x n p p q p px x n x

Page 5: Physics 114: Lecture 9 Probability Density Functions Dale E. Gary NJIT Physics Department

February 12, 2010

Binomial Distribution This is the binomial distribution, which we write PB:

Let’s see if it works. For 1 heads with a toss of 3 fair coins, x = 1, n = 3, p = ½, we get

For no heads, and all tails, we get

Say the coins are not fair, but p = ¼. Then the probability of 2 heads and 1 tails is:

You’ll show for homework that the sum of all probabilities for this (and any) case is 1, i.e. the probabilities are normalized.

!( ; , ) (1 ) .

!( )!x n x

B

nP x n p p p

x n x

1 21 1 12 2 2

3!(1;3, ) 3 / 8.

1!(3 1)!BP

0 31 1 12 2 2

3!(0;3, ) 1/ 8.

0!(3)!BP

21 31 14 4 4

3!(2;3, ) 3 9 / 64 27 / 64.

2!(3 2)!BP

Note: 0! 1

Page 6: Physics 114: Lecture 9 Probability Density Functions Dale E. Gary NJIT Physics Department

February 12, 2010

Binomial Distribution To see the connection of this to the sum of two variables raised to a

power, replace a and b with p and q:

Since p + q = 1, each of these powers also equals one on the left side, while the right side expresses how the probabilities are split among the different combinations. When p = q = ½, for example, the binomial triangle becomes

In MatLAB, use binopdf(x,n,p) to calculate one row of this triangle, e.g. binopdf(0:3,3,0.5) prints 0.125, 0.375, 0.375, 0.125.

0

1

2 2 2

3 3 2 2 3

( ) 1

( )

( ) 2

( ) 3 3

p q

p q p q

p q p pq q

p q p p q pq q

1 1 1 1 2 1 1 3 3 1 1 4 6 4 1

1 1/2 1/2

1/4 2/4 1/4

1/8 3/8 3/8 1/8

1/16 4/16 6/16 4/16 1/16

Page 7: Physics 114: Lecture 9 Probability Density Functions Dale E. Gary NJIT Physics Department

February 12, 2010

Binomial Distribution Let’s say we toss 10 coins, and ask how

many heads we will see. The 10th row of the triangle would be plotted as at right.

The binomial distribution applies to yes/no cases, i.e. cases where you want to know the probability of something happening, vs. it not happening.

Say we want to know the probability of getting a 1, rolling five 6-sided dice. Then p = 1/6 (the probability of rolling a 1 on one die), and q = 1 – p = 5/6 (the probability of NOT rolling a 1). The binomial distribution applies to this case, with PB(x,5,1/6). The plot is shown at right.>> binopdf(0:5,5,1/6.)

ans = 0.4019 0.4019 0.1608 0.0322 0.0032 0.0001

0 2 4 6 8 100

0.1

0.2

0.3

0.4

x

Bin

omia

l Dis

trib

utio

n

Binomial PDF for 10 coins

0 1 2 3 4 50

0.1

0.2

0.3

0.4

0.5PDF for rolling a 1 on five 6-sided dice

Number of 1's rolledB

inom

ial D

istr

ibut

ion

Page 8: Physics 114: Lecture 9 Probability Density Functions Dale E. Gary NJIT Physics Department

February 12, 2010

Binomial Distribution Mean Let’s say we toss 10 coins N = 100 times.

Then we would multiple the PDF by N, to find out how many times we would have x number of heads.

The mean of the distribution is, as before:

For 10 coins, with p = ½, we get = np = 5. For 5 dice, with p = 1/6, we get = np =

5/6.

0 2 4 6 8 100

0.1

0.2

0.3

0.4

x

Bin

omia

l Dis

trib

utio

n

Binomial PDF for 10 coins

0 1 2 3 4 50

0.1

0.2

0.3

0.4

0.5PDF for rolling a 1 on five 6-sided dice

Number of 1's rolledB

inom

ial D

istr

ibut

ion

40

30

20

10

0

0

0

1lim ( ; , )

!(1 )

!( )!

n

i BN

x

nx n x

x

x xP x n pN

nx p p np

x n x

Page 9: Physics 114: Lecture 9 Probability Density Functions Dale E. Gary NJIT Physics Department

February 12, 2010

Binomial Standard Deviation The standard deviation of the

distribution is the “second moment,” given by the variance:

For 10 coins, with p = ½, we get

For 5 dice, with p = 1/6, we get

0 2 4 6 8 100

0.1

0.2

0.3

0.4

x

Bin

omia

l Dis

trib

utio

n

Binomial PDF for 10 coins

0 1 2 3 4 50

0.1

0.2

0.3

0.4

0.5PDF for rolling a 1 on five 6-sided dice

Number of 1's rolledB

inom

ial D

istr

ibut

ion

40

30

20

10

0

2 22

0

2

0

1lim ( ; , )

!(1 ) (1 )

!( )!

n

i BN

x

nx n x

x

x x P x n pN

nx p p np p

x n x

(1 ) 2.5 1.58np p

(1 ) 25 / 36 0.83np p

Page 10: Physics 114: Lecture 9 Probability Density Functions Dale E. Gary NJIT Physics Department

February 12, 2010

Summary of Binomial Distribution

The binomial distribution is PB:

The mean is

The standard deviation is

!( ; , ) (1 ) .

!( )!x n x

B

nP x n p p p

x n x

.np

(1 )np p

Page 11: Physics 114: Lecture 9 Probability Density Functions Dale E. Gary NJIT Physics Department

February 12, 2010

Poisson Distribution An approximation to the binomial distribution is very useful for

the case where n is very large (i.e. rolls with a die with infinite number of sides?) and p is very small—called the Poisson distribution.

This is the case of counting experiments, such as the decay of radioactive material, or measuring photons in low light level.

To derive it, start with the binomial distribution with n large and p << 1, but with a well defined mean = np. Then

The term because x is small, so most of the terms cancel

leaving a total of x terms each approximately equal to n. This gives

1 !( ; , 1) (1 ) .

! ( )!x n x

B

nP x n n p p p

x n x

!.

( )!xn

nn x

1( ; , 1) (1 ) (1 ) (1 ) .

! !

xx n x x n

BP x n n p np p p px x

Page 12: Physics 114: Lecture 9 Probability Density Functions Dale E. Gary NJIT Physics Department

February 12, 2010

Poisson Distribution Now, the term (1 – p)x 1, for small p, and with some algebra we

can show that the term (1 – p)n e. Thus, the final Poisson distribution depends only on x and , and is

defined as

The text shows that the expectation value of x (i.e. the mean) is

Remarkably, the standard deviation is given by the second moment as

These are a little tedious to prove, but all we need for now is to know that the standard deviation is the square-root of the mean.

( ; ) .!

x

PP x ex

0

.!

xn

x

x x ex

2 2 2

0

( ) ( ) .!

xn

x

x x ex

Page 13: Physics 114: Lecture 9 Probability Density Functions Dale E. Gary NJIT Physics Department

February 12, 2010

Example 2.3 Some students measure some background counts of cosmic rays.

They recorded numbers of counts in their detector for a series of 100 2-s intervals, and found a mean of 1.69 counts/interval. They can use the standard deviation formula from chapter 1, which is

to get a standard deviation directly from the data. They do this and get s = 1.29. They can also estimate the standard deviation by

Now they change the length of time they count from 2-s intervals to 15-s intervals. Now the mean number of counts in each interval will increase. Now they measure a mean of 11.48, which implies while they again calculate s directly from their measurements to find s = 3.39.

We can plot the theoretical distributions using MatLAB poisspdf(x,mu), e.g. poisspdf(0:8,1.69) gives ans = 0.1845 0.3118 0.2635 0.1484 0.0627 0.0212 0.0060 0.0014 0.0003

2 21( ) ,is x x

N

1.69 1.30.

11.48 3.17,

Page 14: Physics 114: Lecture 9 Probability Density Functions Dale E. Gary NJIT Physics Department

February 12, 2010

Example 2.3, cont’d The plots of the distributions is

shown for these two cases in the plots at right.

You can see that for a small mean, the distribution is quite asymmetrical. As the mean increases, the distribution becomes somewhat more symmetrical (but is still not symmetrical at 11.48 counts/interval).

I have overplotted the mean and standard deviation. You can see that the mean does not coincide with the peak (the most probable value).

0 2 4 6 80

0.05

0.1

0.15

0.2

0.25

0.3

0.35

Number of Counts

Po

isso

n D

istr

ibu

tion

for

me

an

1.6

9

Probability of counts per interval

0 5 10 15 20 250

0.02

0.04

0.06

0.08

0.1

0.12

Number of Counts per 15 sP

ois

son

Dis

trib

utio

n fo

r m

ea

n 1

1.4

8

Probability of counts per interval

Page 15: Physics 114: Lecture 9 Probability Density Functions Dale E. Gary NJIT Physics Department

February 12, 2010

Example 2.3, cont’d Here is the higher-mean plot with the equivalent Gaussian (normal

distribution) overlaid.

For large means (high counts), the Poisson distribution approaches the Gaussian distribution, which we will describe further next time.

0 5 10 15 20 250

0.05

0.1

0.15

Number of Counts per 15 s

Po

isso

n D

istr

ibu

tion

for

me

an

11

.48

Probability of counts per interval