Written and maintained by CASRAI Editorial Board
Published
On this page
dnorm() is the base R function that returns the height of the normal (Gaussian) probability density curve at one or more values of x. Its call is dnorm(x, mean = 0, sd = 1, log = FALSE), so dnorm(0) returns 0.3989423, the peak of the standard normal curve. The value it returns is a density, not a probability: the probability of landing in a range is the area under the curve, which you get from pnorm().
What dnorm is used for in research
The R manual for the Normal distribution documents four related functions that share one set of arguments: dnorm gives the density, pnorm is the cumulative distribution function, qnorm is the quantile function, and rnorm generates random deviates. Researchers use dnorm when they need the curve itself rather than a tail probability. Typical jobs are:
- drawing a theoretical normal curve over a histogram of observed data to judge fit by eye (see histograms and the normal distribution);
- computing the likelihood of an observation under an assumed normal model, which is the building block of maximum-likelihood estimation;
- checking a hand calculation of the normal probability density function against software output;
- building the weighting or prior terms in simulation and Bayesian code.
Install or access
dnorm belongs to the stats package, which is part of base R and loads automatically in every session. There is nothing extra to install: download R from the Comprehensive R Archive Network at cran.r-project.org, start R (or RStudio, which runs on top of R), and call the function. To open the official help page for the whole family, run ?dnorm, help("Normal") or ?Normal at the console.
Step-by-step: use dnorm
Arguments
The usage line in the R documentation is dnorm(x, mean = 0, sd = 1, log = FALSE).
| Argument | Default | Meaning (R documentation) |
|---|---|---|
x |
none | Vector of quantiles at which the density is evaluated |
mean |
0 | Vector of means |
sd |
1 | Vector of standard deviations |
log |
FALSE | If TRUE, densities are returned as logarithms |
Steps
- Start with the standard normal. Run
dnorm(0). The result is 0.3989423, which equals 1/√(2π), the maximum height of the standard normal curve. - Change the distribution. Supply
meanandsdby name:dnorm(1, mean = 2, sd = 0.5)returns 0.1079819. - Evaluate many points at once. The arguments are vectorised, so
dnorm(c(-1, 0, 1))returns three densities in one call (0.2419707, 0.3989423, 0.2419707). - Draw the curve. Create a grid of x values and plot the densities:
x <- seq(-4, 4, length.out = 200) plot(x, dnorm(x), type = "l", xlab = "x", ylab = "Density") - Overlay it on data. For a numeric vector
y, draw a density-scaled histogram and add the fitted normal curve:hist(y, freq = FALSE) curve(dnorm(x, mean = mean(y), sd = sd(y)), add = TRUE) - Get log-densities when you need a log-likelihood.
dnorm(y, mean = mean(y), sd = sd(y), log = TRUE)returns the log of each density, andsum()of that vector is the normal log-likelihood of the sample at those parameter values.
Output and how to read it
Density is a height, not a probability
The documented density is f(x) = 1/(√(2π) σ) · exp(−(x − μ)² / (2σ²)). Because it is a height on a curve whose total area is 1, it can exceed 1 when the standard deviation is small. With mean = 0.5 and sd = 0.1, the peak is about 3.989, and dnorm(0.4, mean = 0.5, sd = 0.1) is about 2.4197. This is legitimate: the narrower the curve, the taller it must be to keep an area of 1. Read the value as “how concentrated the distribution is near this x”, and compare densities only for the same distribution.
From density to probability
To get the probability that a value falls between two points, subtract cumulative probabilities: pnorm(b, mean, sd) - pnorm(a, mean, sd). The companion guide to pnorm in R covers that function. For a lookup in the other direction, qnorm converts a probability into a quantile.
Verifying by hand
You can reproduce any output from the documented formula. For dnorm(1, mean = 2, sd = 0.5): (x − μ)² / (2σ²) = 1 / 0.5 = 2, so the density is exp(−2) / (√(2π) × 0.5) = 0.135335 / 1.253314 = 0.1079819, matching the function.
Worked values
The data table below the guide lists densities computed from the documented formula for several x, mean and sd combinations, together with their natural logarithms (what log = TRUE returns).
dnorm vs pnorm, qnorm and rnorm
All four functions take the same mean and sd arguments. Use dnorm for the height of the curve at a point, pnorm for the probability of a value at or below a point, qnorm for the point that corresponds to a given cumulative probability, and rnorm to simulate data. The same pattern exists for other distributions: the t distribution is covered in pt in R.
Edge cases defined in the documentation
sd = 0gives the limit as the standard deviation decreases to 0, a point mass at the mean.- A negative
sdis an error and returnsNaN. - Arguments are recycled, so a single
meanandsdapply to every element ofx, while vectors of different values are matched element by element.
Worked example: a log-likelihood by hand
Suppose three observations y = 4, 5 and 6 are assumed to come from a normal distribution with mean 5 and standard deviation 1. In R, sum(dnorm(c(4, 5, 6), mean = 5, sd = 1, log = TRUE)) adds the three log-densities. By the documented formula, the log-density is −log(√(2π)) − (x − μ)²/2, which is −0.9189385 − (x − 5)²/2. That gives −1.4189385 for y = 4, −0.9189385 for y = 5 and −1.4189385 for y = 6, so the sum is −3.7568155. Summing logs rather than multiplying densities avoids the tiny products that underflow with large samples. Varying mean and sd and keeping the pair with the largest sum is the idea behind maximum-likelihood estimation.
Troubleshooting
- Warning “NaNs produced”. Check for a negative
sd; the documentation says this returnsNaN. A common cause is passing a variance, or a computed value that has gone negative, instead of a standard deviation. - Density above 1. Not an error; see the section above. If you wanted a probability, use
pnormdifferences. - Curve invisible on a histogram. A histogram drawn with counts sits on a much larger scale than the density. Use
hist(y, freq = FALSE)so both are on the density scale. - Wrong result from positional arguments. The second argument is
meanand the third issd. Name them (mean =,sd =) to avoid swapping them. - Zero density in the tails. Very extreme x values underflow to 0. Use
log = TRUEwhen you are summing log-likelihoods. - Could not find function. Check the spelling: the function is lowercase
dnorm, and R is case sensitive.
Free alternatives
R itself is free, and so is the Python equivalent. SciPy’s scipy.stats.norm exposes the same density with different argument names: loc is the mean and scale is the standard deviation. The SciPy documentation states that norm.pdf(x, loc, scale) is identically equivalent to norm.pdf(y) / scale with y = (x - loc) / scale, and that the standard form is f(x) = exp(−x²/2) / √(2π).
| Task | R (stats, base) | Python (SciPy) |
|---|---|---|
| Normal density | dnorm(x, mean, sd) |
scipy.stats.norm.pdf(x, loc, scale) |
| Default parameters | mean = 0, sd = 1 | loc = 0, scale = 1 |
| Log density | dnorm(x, mean, sd, log = TRUE) |
scipy.stats.norm.logpdf(x, loc, scale) |
FAQ
What does dnorm do in R?
It returns the probability density of the normal distribution at the values you give it, using the mean and standard deviation you supply (0 and 1 by default).
What is the difference between dnorm and pnorm?
dnorm is the height of the bell curve at a point; pnorm is the cumulative probability up to that point, that is, the area under the curve to its left. See pnorm in R.
Why is my dnorm result greater than 1?
Because it is a density. When the standard deviation is below about 0.4 the peak 1/(√(2π) σ) exceeds 1, and the total area under the curve is still 1.
How do I use dnorm in R with my own data?
Estimate the mean and standard deviation from the sample and pass them in: dnorm(x, mean = mean(y), sd = sd(y)), as in step 5 above.
Is “dnorm r” the same function?
Yes. Searches for “dnorm r” refer to the same R function, dnorm; the letter R names the language.
Sources
- R Core Team, The Normal Distribution, R stats manual: stat.ethz.ch/R-manual/R-devel/library/stats/html/Normal.html (read 2026-11-12).
- SciPy documentation, scipy.stats.norm: docs.scipy.org (read 2026-11-12).
- The Comprehensive R Archive Network: cran.r-project.org.
Data: dnorm() values computed from the documented normal density formula
Normal density and log-density at selected x, mean and sd values, computed from the formula f(x) = exp(-(x-mu)^2/(2 sigma^2))/(sqrt(2 pi) sigma) given in the R stats manual for the Normal distribution; each row corresponds to one dnorm() call.
| R call | x | mean | sd | Density (dnorm) | Log density (log = TRUE) |
|---|---|---|---|---|---|
| dnorm(0, mean = 0, sd = 1) | 0 | 0 | 1 | 0.3989423 | -0.9189385 |
| dnorm(1, mean = 0, sd = 1) | 1 | 0 | 1 | 0.2419707 | -1.4189385 |
| dnorm(2, mean = 0, sd = 1) | 2 | 0 | 1 | 0.053991 | -2.9189385 |
| dnorm(0.5, mean = 0, sd = 1) | 0.5 | 0 | 1 | 0.3520653 | -1.0439385 |
| dnorm(1, mean = 2, sd = 0.5) | 1 | 2 | 0.5 | 0.1079819 | -2.2257914 |
| dnorm(0.4, mean = 0.5, sd = 0.1) | 0.4 | 0.5 | 0.1 | 2.4197072 | 0.8836466 |
| dnorm(0.5, mean = 0.5, sd = 0.1) | 0.5 | 0.5 | 0.1 | 3.9894228 | 1.3836466 |
| dnorm(170, mean = 175, sd = 7) | 170 | 175 | 7 | 0.0441593 | -3.1199507 |
Sources
- R stats manual: The Normal Distribution (accessed 2026-11-12)
Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.







