4
$\begingroup$

I'm a huge newbie when it comes to statistics and R.

I'm trying to make sense of all of these functions as someone who hasn't taken statistics before.

In R, from what I've understood, with dbinom, you enter the number of trials, the probability of success, and a number of successes n, all as arguments, and it returns the probability that the trial will succeed n times in a certain number of traiils. Is this correct? dbinom is the probability density function, right?

As you can probably tell, there are a lot of things I'm confused about.

First, can a probability density function only return a non-zero probability if the data is discrete?

pbinom is the cumulative version of the probability density function, correct? If the data is continuous, I would use the cumulative function, right?

And now for the big question, what is the difference between dbinom/pbinom and dnorm/pnorm?

From my understanding, pbinom gives you that probability that I first mentioned. You enter an number of successes, number of trials, and probability of success, and it returns a probability. However, with dnorm, I don't understand what it is I enter. I know that I enter an x (which presumably also represents a number of successes), as well as a mean and a standard deviation. I also know that it does this for a normal distribution. What I don't understand is, why doesn't it ask for a probability, or a number of trials. Why does the x axis have negative values this time? What does it even return? Shouldn't it return 0 since presumably it's not discrete? I know that it actually returns the calculation from the equation (the one with the standard deviation and mean), but I don't know what the equation really even represents.

Can someone set me on the right track, because I feel lost in all these terms, equations, and functions.

$\endgroup$
2
  • $\begingroup$ Welcome to the site. Please have a look at R's documentation, either by typing ?pnorm in the console or have a look at rdocumentation.org/packages/stats/versions/3.4.3/topics/Normal. $\endgroup$
    – Jim
    Commented Mar 22, 2018 at 22:08
  • $\begingroup$ Thank you. I actually have looked through it quite a bit, but embarrassingly enough, I'm too ignorant as of now to actually make sense of the explanations given by explanations. $\endgroup$ Commented Mar 22, 2018 at 22:30

4 Answers 4

7
$\begingroup$

And now for the big question, what is the difference between dbinom/pbinom and dnorm/pnorm?

dbinom is a probability mass function of binomial distribution, while pbinom is a cumulative distribution function of this distribution. The first one tells you what is $\Pr(X=x)$ (probability of observing value equal to $x$), while the second one, what is $\Pr(X \le x)$ (probability of observing value smaller or equal then $x$). Notice that cumulative distribution function has nothing to do with data being continuous, or discrete, there are cumulative distribution functions for both kind of variables (and for mixed types).

As about dnorm, it is a probability density function, to learn more about it see the Can a probability distribution value exceeding 1 be OK? thread.

$\endgroup$
2
  • $\begingroup$ Thank you very much for the explanation. Just to clear some things up: the cumulative distribution function can be for any kind of data, but the pbinom function creates one for discrete data, as binomial distribution deals with discrete variables? Is that correct? $\endgroup$ Commented Mar 22, 2018 at 22:23
  • 1
    $\begingroup$ @user494405 cumulative distribution function is a type of function that tells you about cumulative probabilities. Binomial, or normal (or many others) are kinds of random variables. $\endgroup$
    – Tim
    Commented Mar 22, 2018 at 22:37
3
$\begingroup$

You could try to draw them for illustration:

  • dnorm is a probability density function so the area under the curve (from $-\infty$ to $\infty$) is $1$ and the tails fall towards $0$. A normal density can be sometimes be above $1$ when the variance is below $\frac{1}{2\pi}$

  • dbinom is a probability mass function taking positive values only at discrete points and the sum of the probabilities is $1$. So none of the individual probabilities can exceed $1$

  • pnorm is cumulative distribution function going from $0$ on the left to $1$ on the right. A normal distribution is continuous and so is its cumulative distribution function

  • pbinom is cumulative distribution function going from $0$ on the left to $1$ on the right. A binomial distribution is discrete, so its cumulative distribution function jumps up in steps at the discrete values

The following takes a $N(2,\frac43)$ distribution and $Bin(6,\frac13)$ distribution for illustration since they have the same mean and variance

enter image description here

$\endgroup$
1
  • $\begingroup$ Perfect answer. I'm not sure if the central limit theorem exactly applies here, but is the basic idea, that as the sample space approaches infinity, the cumulative distribution function for a binomial distribution becomes effectively the same as that for a normal distribution? -- sorry I'm a little late to the party. $\endgroup$ Commented May 20, 2021 at 22:47
2
$\begingroup$

Kudos at learning this material separate from having taking a statistics (¿or probability?) course.  There is a lot to unpack here, and it may be better to do some external reading, but I will start with an explanation of dnorm vs pnorm.

In R, dnorm() draws the curve that we will use to calculate our probabilities.  This is the conventional normal curve with which most people are familiar.  To calculate a probability, we are actually calculating an area.  In particular, we are going to cut a vertical line through this curve, shade the area under the curve to the left of the vertical line, and this is the probability value.

So, dnorm(2) gives the height of this curve at $x=2$ whereas pnorm(2) gives the area under the curve from $-\infty$ to $x=2$.

Regarding your query about have a zero probability for a value with a continuous distribution...you are on the right track.  Using a little bit of limits, if you have pnorm(2) - pnorm(1.5), this is the area under the curve from $x=1.5$ to $x=2$.  If you start to move $x=1.5$ closer to 2, this area becomes zero.

Note, I have omitted more technical terms like density function and cumulative probability distribution, but I think a more general picture may help here.

$\endgroup$
2
  • $\begingroup$ Thank you very much for your response. That does clear some things up. I do have some follow up questions, if you don't mind. Let's say I use dnorm at 0. It's calculating the height of the curve at x=0. What does x represent here? Also, what does the height of the curve represent? Furthermore, if I add all the dbinom from x1 to x2, I would get the equivalent of pbinom of x2, right? Why is this not true for dnorm and pnorm? Is it because it's continuous? Again, thank you very much for the help. $\endgroup$ Commented Mar 22, 2018 at 22:10
  • $\begingroup$ I meant so say that I took the sum of all dbinoms from 0 to x2, my apologies. $\endgroup$ Commented Mar 22, 2018 at 22:17
1
$\begingroup$

Really short answer:

use 'dbinom' if you want to know the probability of exactly k successes in N trials.

two heads in 3 coinflips.

use 'pbinom' if you want to know the probability of at least k successes in N trials. at least two heads in 3 coinflips.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.