Tip:
Highlight text to annotate it
X
Hi! I am Mike Marin and in this video
we'll talk about calculating probabilities for a binomial random
variable using R.
Throughout this video
we will focus on a random variable known to follow a binomial distribution
with n equal to 20 (n=20) trials and a probability of success,
p equals 1/6 (p=1/6). We can calculate probabilities for the binomial
using the "pbinom" or "dbinom" functions. To access the Help menu
type "help" and in brackets the name of the command
you would like help for or simply throw a question mark (?)
in front of the name.
The "dbinom" command can be used to find values for the probability density function of X.
Suppose we would like to find
the probability that X is exactly equal to 3 (X=3).
We can use the "dbinom" function;
here we would like the probability
associated with X equals three (X=3).
the size of our sample is 20, the probability of success is 1/6.
We can see
that the probability of exactly 3 successes on 20 trials
is approximately 23.8%. We can also have multiple
probabilities returned. Suppose for example
we would like to find the probability that X equals 0
and the probability that X equals 1
and all the way up to
probability that X equals 3. To do so
we can again use the "dbinom" command and here we would like probabilities
for X equals 0 up to X equals 3.
We can now see
there's approximately 2.6 percent probability
of exactly 0 successes, approximately a 10.4 percent chance of
exactly 1 success.
Now suppose we would like to find the probability that X
is less than or equal to 3, that is
we have zero successes or 1 or 2 or 3.
We can find this probability
in a few different ways: the first being that we can take
those probabilities calculated earlier and sum them all up
using the "sum" command.
Here we can see there's approximately 56.6% chance
of 3 or fewer successes. We can also calculate
the probability of 3 or fewer successes using the
"pbinom" command. This returns values for the probability distribution function.
To find the probability of 3 or fewer successes,
we would like the probability for binomial value of 3, again 20 trials,
our probability of success
is 1/6 and here we include
lower tail equals to TRUE letting R know
we would like the probability of less than or equal to 3.
The "rbinom" command can be used to take a random sample
from a binomial distribution and
the "qbinom" command may be used to find quantiles
for the binomial distribution. Check out my video on the normal distribution
for some insight on how to use these.
Thanks for watching this video and make sure to check out my other instructional videos.