# What is the difference between dbinom and dnorm in R?

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 trails, the probability of success, and a number of successes n, all as arguments, and it returns the probability that the trail will succeed n times in a certain number of trails. 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.

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

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

And now for the big question, what the hell 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 trails, and probability of succes, 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 trails. Why does the x axis have negative values this time? What does it even return? Shoudn't it return 0 since presumably its 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.

Am I even making sense? I feel like I'm just spewing gibberish at this point.

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

Any help is greatly appreciated. Thank you.

• 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. – Jim Mar 22 '18 at 22:08
• 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. – iaskdumbstuff Mar 22 '18 at 22:30

And now for the big question, what the hell 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.

• 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? – iaskdumbstuff Mar 22 '18 at 22:23
• @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. – Tim Mar 22 '18 at 22:37

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.

• 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. – iaskdumbstuff Mar 22 '18 at 22:10
• I meant so say that I took the sum of all dbinoms from 0 to x2, my apologies. – iaskdumbstuff Mar 22 '18 at 22:17

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 