Objectives

If you’ve never coded before (or even if you have), type "Your Name" in the interactive R chunk below and run it by hitting crtl+Enter or cmd+Enter for MAC users.

Throughout this tutorial you’ll be introduced to the notion of probability and will explore applications of probability and discrete random variables. In particular we will focus on binomial experiments and using the binomial distribution to find probabilities of prescribed outcomes.

Note: There are entire courses devoted to probability – we will only cover probability to the extent that it is necessary for use in this course. If you are interested in a more detailed treatment of probability, seek out one of the many great courses available.

Tutorial Objectives: After completing this tutorial you should be able to:

  • Define, discuss, and interpret the probability of an event as its likelihood.
  • Apply fundamental counting principles and the notion of independence to compute the probability associated with the occurrence of a sequence of events.
  • Use the definition of binomial experiments to identify scenarios to which the binomial distribution can be applied and then actually apply the distribution to find probabilities associated with specified outcomes.
  • Given a binomial experiment, compute the expected number of successful outcomes as well as the standard deviation for number of successes.

Basic Probability

Definition of Probability (frequentist): For a given random process, the probability of an event \(A\) is the proportion of time we would observe outcome \(A\) if the random process were repeated an infinite number of times.

Example: Given a fair coin, the probability of a flip turning up heads is \(0.5\) (or 50%). Similarly, given a fair six-sided die, the probability of a roll resulting in a number greater than four is \(1/3\) (or about 33.3%) because there are two outcomes satifying the criteria (rolling a 5 or rolling a 6) out of the six total possible outcomes.

Try It! Now it is your turn. Try the next few problems. Be sure to note any questions you have as you work through them.

Quiz

Good work on that last set of questions. In those problems you could find the probability by counting the number of ways the desired outcome could occur and then dividing that number by the total number of outcomes possible. In the last question, there were simply more ways to roll a five (four ways to do it) than to roll a two (just one way). What if we try doing something a bit more complicated? Say we wanted to know the probability of rolling at least a two on a single roll of a die and then flipping a “tails” on a single flip of a coin?

Probability and Independent Events: If \(A\) and \(B\) are independent events (that is, the probability that \(B\) occurs does not depend on whether or not \(A\) occured and vice-versa), then the probability of \(A\) and \(B\) occurring is the product of the probability of \(A\) occurring and the probability of \(B\) occurring. Mathematically, we write: \(\mathbb{P}\left[A~\text{and}~B\right] = \mathbb{P}\left[A\right]\cdot\mathbb{P}\left[B\right]\).

Quiz

Use the code block below to compute the probability that in a single roll of a fair die and a flip of a coin we observe a roll of at least two and a flip of tails.

Good work so far. Let’s say you forgot to study for your chemistry quiz today. It is a four question multiple choice quiz with options \(a)\) - \(e)\). You decide that your best option is to guess randomly on each of the questions. Answer the following, using the empty code block below to carry out any necessary computations.

Quiz

Binomial Experiments and the Binomial Distribution

Binomial Experiments: A binomial experiment satisfies each of the following three criteria:

  • There are \(n\) repeated trials.
  • Each trial has two possible outcomes (usually called success and failure for convenience)
  • The trials are independent of one another. That is, for each trial, the probability of success is \(p\) (which remains constant).

Binomial Distribution: Let \(X\) be the number of successes resulting from a binomial experiment with \(n\) trials. We can compute the following probabilities:

  • The probability of exactly \(k\) successes is given by
    \(\displaystyle{\mathbb{P}\left[X = k\right] = \binom{n}{k}\cdot p^k\left(1 - p\right)^{n-k} \approx \tt{dbinom(k, n, p)}}\)
  • The probability of at most \(k\) successes is given by
    \(\displaystyle{\mathbb{P}\left[X \leq k\right] = \sum_{i=0}^{k}{\binom{n}{i}\cdot p^i\left(1 - p\right)^{n-i}} \approx \tt{pbinom(k, n, p)}}\)

In the equations above, \(\binom{n}{k} = \frac{n!}{k!\left(n-k\right)!}\) counts the number of ways to arrange the \(k\) successes amongst the \(n\) trials. That being said, the R functionality, dbinom() and pbinom() allow us to bypass the messy formulas – but you’ll still need to know what these functions do in order to use them correctly!

Tip: We need to use the binomial distribution to find probabilities associated with numbers of successful (or failing) outcomes in which we do not know for certain the trials on which the successes (or failures) occur.

The code block below is set up to find the probability of exactly two flips of a coin landing heads-up out of seven total flips. Edit the code block that that it finds the probability that you got exactly two of the four questions on your chemistry quiz from earlier correct. As a reminder, there were five answer options for each question and you were guessing randomly.

dbinom(2, 7, 0.5)
[1] 0.1640625

Good work. Now you’ll get to try a few more problems! As you work through the next set of questions, you may want to check out this example and solution. Note that in that document, I mention that drawing a simple picture for each problem will help you decide which function(s) you might use and whether you might need to make multiple computations. This is a really important strategy that will help you in developing a strategy to solve each problem.

Practice: For each of the following, consider a scenario in which a random sample of 18 students is asked (in private) whether they’ve failed to hand in at least one assignment this semester. We assume that about 34% of students fail to hand in at least one assignment.

  1. Find the probability that exactly 7 of the 18 students have failed to hand in at least one assignment.

Example: Find the probability that at most 15 of the 18 students have failed to hand in at least one assignment. That is,

\(\displaystyle{\mathbb{P}\left[X \leq 15\right] = \sum_{i=0}^{15}{\binom{18}{i}\cdot 0.34^{i}\left(1 - 0.34\right)^{18-i}} \approx \tt{pbinom(15, 18, 0.34)}})\)

pbinom(15, 18, 0.34)
## [1] 0.9999977
  1. Find the probability that at most 9 of the 18 students have failed to hand in at least one assignment.

Example: Find the probability that at least 5 of the 18 students have failed to hand in at least one assignment. That is,

\(\displaystyle{\mathbb{P}\left[X \ge 5\right] = 1 - \mathbb{P}\left[X \le 4\right] = \tt{1 - pbinom(4, 18, 0.34)}}\)

1 - pbinom(4, 18, 0.34)
## [1] 0.7865908
  1. Find the probability that at least 11 of the 18 students have failed to hand in at least one assignment.

Example: Find the probability that at least 10 and at most 15 students have failed to hand in at least one assignment. That is,

\(\displaystyle{\mathbb{P}\left[10 \le X \le 15\right] = \mathbb{P}\left[X \le 15\right]-\mathbb{P}\left[X \le 9\right] = \tt{pbinom(15, 18, 0.34) - pbinom(9, 18, 0.34)}}\)

pbinom(15, 18, 0.34) - pbinom(9, 18, 0.34)
## [1] 0.04942319
  1. Find the probability that between a minimum of 6 and a maximum of 12 out of the 18 students have failed to hand in at least one assignment.

  1. The expected number of successes in a binomial experiment is sometimes denoted by \(\mathbb{E}\left[X\right]\) or \(\mu\), and it can be computed as \(\mu = \mathbb{E}\left[X\right] = n\cdot p\), where \(n\) denotes the number of trials run and \(p\) denotes the probability of success on a single trial. Sometimes it is convenient to think of the expected number of successes as “the mean”. Use the code block below to compute the expected number of students who have failed to hand in at least one assignment:
  2. The standard deviation in the number of successes for a binomial experiment can also be computed. The quantity \(\displaystyle{\sigma = \sqrt{n\cdot p\left(1 - p\right)}}\), where \(n\) denotes the number of trials run and \(p\) denotes the probability of success on a single trial is the standard deviation in number of successes. Use the code block below to compute the standard deviation in number of students who have failed to hand in at least one assignment from random samples of 18 students:

Be sure to write down what questions you had as you worked through these problems and to have a teacher, colleague, or tutor help clarify things for you.

Submit

If you have completed this tutorial and are happy with all of your solutions, please click the button below to generate your hash and submit it using the corresponding tutorial assignment tab on Blackboard


NCAT Blackboard

Summary

Up to this point you’ve been exposed to basic probability, binomial experiments, and using the binomial distribution. Here’s a quick recap.

  • The probability of an event \(A\) is a measure of the likelihood of \(A\) occurring, and is denoted by \(\mathbb{P}\left[A\right]\).
  • The probability of any event must be between \(0\) and \(1\)
  • A binomial experiment satisfies each of the following
    • The experiment consists of \(n\) repeated trials
    • Each trial has two possible outcomes
    • The trials are independent of one another
  • If \(X\) denotes the number of successes resulting from a binomial experiment with \(n\) trials and probability of success on a single trial equal to \(p\), then
    • \(\mathbb{P}\left[X = k\right] \approx \tt{dbinom(k, n, p)}\)
    • \(\mathbb{P}\left[X\leq k\right] \approx \tt{pbinom(k, n, p)}\)
    • Drawing a picture is a crucial step along the way to solving a probability problem. The two functions above are enough to compute the probability of any type of outcome associated with a binomial experiment – the trick is in finding how to put these tools to use – drawing a picture will guide you.
    • The expected value of \(X\) (expected number of successes) is given by \(\mu = \mathbb{E}\left[X\right] = n\cdot p\)
    • The standard deviation of \(X\) (standard deviation of number of successes) is given by \(\sigma = \sqrt{n\cdot p\left(1 - p\right)}\)