73
Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2

Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

  • Upload
    others

  • View
    42

  • Download
    5

Embed Size (px)

Citation preview

Page 1: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

Probability Density Functions and the Normal Distribution

Quantitative Understanding in Biology, 1.2

Page 2: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

1. Discrete Probability Distributions

Page 3: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

1.1. The Binomial Distribution

Page 4: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

You’ve decided to flip a coin. What’s the probability the coin will come up heads? Tails? What about heads 10 times in a row? What about heads, then, tails, then head again?

Question:

Page 5: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

Proposition:

You don’t need to flip any coins. If your coin is fair, coin flips follow the binomial distribution.

Page 6: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

A probability distribution function is a function that relates an event to

the probability of that event.

Page 7: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

If the events are discrete (i.e. they correspond to a set of specific numbers or specific “states”), we describe it with

a probability mass function.

Page 8: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

p x( ) =

x = x1x = x2!

x = xn

p1p2!pn

⎪⎪

⎪⎪

Page 9: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

p x( ) ≥ 0

pii=1

n

∑ = 1

Page 10: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

[R Example]

To be added to notes. See code on next slide.

Page 11: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

# ROLL A FAIR 6-SIDED DIE sample(1:6, 4, replace=TRUE)

# ROLL AN UNFAIR 5-SIDED DIE sample(1:5, 4, replace=TRUE, prob=c(0.1, 0.3, 0.4, 0.05, 0.05))

# SAMPLE FROM A SET OF COLORS sample(c("red", "blue", "green", "white", "black"), 4,

replace=TRUE, prob=c(0.1, 0.3, 0.4, 0.05, 0.05))

Page 12: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

Proposition:

You don’t need to flip any coins. If your coin is fair, coin flips follow the binomial distribution.

Page 13: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

p x( ) = x = success psuccessx = failure 1− psuccess

⎧⎨⎪

⎩⎪

The  Binomial  Distribution

Page 14: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

p x( ) = x = heads 0.5x = tails 0.5

⎧⎨⎩

The  Fair  Coin

Page 15: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

What about multiple coin flips?

Question:

Page 16: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

If you are fairly flipping a fair coin, each coin flip is independent and identically distributed, also known

as iid.

Page 17: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

p heads,heads,tails( ) = p heads( ) p heads( ) p tails( )

Independent  Fair  Coin  Flips

Page 18: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

p # flips = n( ) = 0.5n

Independent  Fair  Coin  Flips

Page 19: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

When you sample a binomial distribution multiple times, you are

performing a Bernoulli trial.

Page 20: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

We can perform Bernoulli trials in R

Page 21: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

[R Example]

See notes.

Page 22: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

Often it is useful to calculate cumulative probabilities; for

example, the probability of 7 or more heads when you flip 10 coins.

Page 23: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

P ≤ # successes, # trials( ) = p successes = i,trials = # trials( )i=0

# successes

∑P ≥ # successes, # trials( ) = 1− P ≤ # successes, # trials( )

Page 24: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

[R Example]

See notes.

Page 25: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

1.2. The Poisson Distribution

Page 26: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

[R Example]

See notes.

Page 27: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

The Poisson distribution describes the probability of a certain number of events occurring within a given

time interval.

Page 28: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

p # events = k( ) = λ ke−λ

k!

The  Poisson  Distribution

Page 29: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete
Page 30: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

1.3. The Geometric Distribution

Page 31: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

You flipped heads. How many tails will you flip before you flip heads

again? The Geometric distribution describes the probability of a given “waiting time” between successes.

Page 32: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

p wait = k( ) = psuccess 1− psuccess( )k

The  Geometric  Distribution

Page 33: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete
Page 34: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

[R Example]

See notes.

Page 35: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

1.3. Uniform Distributions

Page 36: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

p x( ) = 1n

The  Uniform  Distribution

Page 37: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

p x( ) = 1n

The  Uniform  Distribution

Page 38: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

2. Continuous Probability Distributions

Page 39: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

If the events correspond to real numbers, we describe it with a

probability density function.

Page 40: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete
Page 41: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

f x( ) ≥ 0f x( )

−∞

∫ dx = 1

Page 42: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

2.1. The Uniform Distribution

Page 43: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

The Uniform distribution defines an interval in which the probability

density is uniform. Outside of this interval, the probability is 0.

Page 44: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

f x( ) =x < a

a ≤ x ≤ bx > b

01

b − a0

⎨⎪⎪

⎩⎪⎪

The  Uniform  Distribution

Page 45: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete
Page 46: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

[R Example]

See notes.

Page 47: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

2.2. The Exponential Distribution

Page 48: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

f x( ) = λe−λx

The  Exponential  Distribution

Page 49: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete
Page 50: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

[R Example]

See notes.

Page 51: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

2.3. The Normal Distribution

Page 52: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete
Page 53: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

f x( ) = e−x−µ( )2σ 2

2

σ 2π

The  Normal  Distribution

Page 54: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete
Page 55: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

[R Example]

See notes.

Page 56: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

3. Central Limit Theorem

Page 57: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

If you measure the mean of a distribution many, many times,

those means will tend to become normally distributed.

Page 58: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete
Page 59: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

Central Limit Theorem implies: 1. If you sample enough, your

estimate of the mean will converge to the true mean.

2. If your measurement is the average of many independent

processes, it will tend to be normally distributed.

Page 60: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

Central Limit Theorem implies: 1. If you sample enough, your

estimate of the mean will converge to the true mean.

2. If your measurement is the average of many independent

processes, it will tend to be normally distributed.

Page 61: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

Central Limit Theorem implies: 1. If you sample enough, your

estimate of the mean will converge to the true mean.

2. If your measurement is the average of many independent

processes, it will tend to be normally distributed.

Page 62: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

Question:

So you have some data. What should I do with it?

Page 63: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

Step 1. Test for normality.

Page 64: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

Step 1.1. Look at your data.

Page 65: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

One of the easiest ways to “look at your data” is to make a Q-Q plot.

Page 66: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete
Page 67: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete
Page 68: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

[R Example]

See notes.

Page 69: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

Step 1.2. Do a statistical test.

Page 70: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

In the Kolmogorov-Smirnov test, you estimate the probability that your data comes from the normal

distribution from the distance between the two cumulative

distribution functions.

Page 71: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete
Page 72: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

[R Example #8]

See notes.

Page 73: Probability Density Functions and the Normal Distribution€¦ · Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology, 1.2. 1. Discrete

Homework: Generate Q-Q plots