I know count is simply the amount of times the observations occur in a single bin width, but what is density?


3 Answers 3



Suppose $X_1, X_2, \dots, X_{100}$ is a random sample of size $n$ from a normal distribution with mean $\mu=100$ and standard deviation $\sigma=12.$ Also, we have bins (intervals) of equal width, which we use to make a histogram.

The vertical scale of a 'frequency histogram' shows the number of observations in each bin. Optionally, we can also put numerical labels atop each bar that show how many individuals it represents.

enter image description here

The vertical scale of a 'density histogram' shows units that make the total area of all the bars add to $1.$ This makes it possible to show the density curve of the population using the same vertical scale.

From above, we know that the tallest bar has 30 observations, so this bar accounts for relative frequency $\frac{30}{100} = 0.3$ of the observations. The width of this bar is $10.$ So its density is $0.03$ and its area is $0.03(10) = 0.3.$ The density curve of the distribution $\mathsf{Norm}(100, 15)$ is also shown superimposed on the histogram. The area beneath this density curve is also $1.$ (By definition, the area beneath a density function is always $1.)$ Optionally, I have added tick marks below the histogram to show the locations of the individual observations.

enter image description here

Definitions: If the frequency of the $i$th bar is $f_i,$ then its relative frequency is $r_i = f_i/n,$ where $n$ is the sample size. Its density is $d_i = r_i/w_i,$ where $w_i$ is its width. Ordinarily, you should make a density histogram only if each bar has the same width.

Notes: (1) Another type of histogram (that you did not ask about) would be a 'relative frequency' histogram with relative frequencies (not densities) on the vertical scale. (2) The sample mean of the data shown is $\bar X =102.98$ and the sample standard deviation is $S = 15.37.$ (3) These histograms were made using R statistical software.

  • 4
    $\begingroup$ If I had a winning lottery ticket, I'd give it to you $\endgroup$ Feb 26, 2018 at 16:29
  • $\begingroup$ What if there are no bins? For instance, how would you find a density function for a discrete random variable? How can you still find the area under it? $\endgroup$ Apr 25, 2021 at 19:18
  • $\begingroup$ If there are finitely many discrete values as for a binomial, $n$ trials then you might use 'categories" 1 through $n.$ [Depending on the number of observations, you might have to combine categories to avoid sparse data.] For a discrete RV with countably many values (such as Poisson), then you'd have to use a category like "k or more." // Why not start a new Question with a specific discrete distribution along with a tabulation of results from many realizations. // Examples: 120 rolls of a fair die; 1000 observations from $\mathsf{Binom}(n=5, p = .3).$ $\endgroup$
    – BruceET
    Apr 25, 2021 at 19:37

The bin counts can sum to any whole number.

The bin densities sum to one, as integrating the pdf yields unit area.


The area of the bars of frequency density histogram will NOT be 1. Even when the widths of the bars are the same, say, $w$, the area will be $1/w!$ Do any example.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .