Get startedGet started for free

Continuous distributions

1. Continuous distributions

We can use discrete distributions to model situations that involve discrete or countable variables, but how can we model continuous variables?

2. Waiting for the bus

Let's start with an example. The city bus arrives every twelve minutes, so if you show up at a random time, you could wait anywhere from 0 minutes if you arrive just as the bus pulls in, up to 12 minutes if you arrive as the bus leaves.

3. Continuous uniform distribution

Let's model this scenario with a probability distribution. There are an infinite number of minutes we could wait since we could wait 1 minute, 1-point-5 minutes, 1-point-53 minutes, and so on, so we can't create individual blocks like we could with a discrete variable.

4. Continuous uniform distribution

Instead, we'll use a continuous line to represent probability. The line is flat since there's the same probability of waiting any time from 0 to 12 minutes. This is called the continuous uniform distribution

5. Probability still = area

Now that we have our distribution, let's figure out what the probability is that we'll wait between 4 and 7 minutes. Just like with discrete distributions, we can take the area from 4 to 7 to calculate probability.

6. Probability still = area

The width of this rectangle is 7 minus 4 which is 3. The height is one twelfth.

7. Probability still = area

Multiplying those together to get area, we get 3/12 or 25%.

8. Uniform distribution in R

Let's use the uniform distribution in R to calculate the probability of waiting 7 minutes or less. We'll pass 7 into punif. It also takes in a min and a max, which in our case is 0 and 12. The probability of waiting less than 7 minutes is about 58%.

9. lower.tail

If we want the probability of waiting more than 7 minutes, set the lower-dot-tail argument to FALSE.

10. Combining multiple punif() calls

But how do we calculate the probability of waiting 4 to 7 minutes using R?

11. Combining multiple punif() calls

We can start with the probability of waiting less than 7 minutes,

12. Combining multiple punif() calls

then subtract the probability of waiting less than 4 minutes. This gives us 25%.

13. Total area = 1

To calculate the probability of waiting between 0 and 12 minutes, we multiply 12 by 1/12, which is 1.

14. Total area = 1

or 100%. This makes sense since we're certain we'll wait anywhere from 0 to 12 minutes.

15. Other continuous distributions

Continuous distributions can take forms other than uniform where some values have a higher probability than others.

16. Other continuous distributions

No matter the shape of the distribution, the area beneath it must always equal 1.

17. Other special types of distributions

This will also be true of other distributions you'll learn about later on in the course, like the normal distribution or Poisson distribution, which can be used to model many real-life situations.

18. Let's practice!

Time to practice working with continuous distributions.