# Difference between histogram and pdf?

If we want to visibly see the distribution of a continuous data, which one among histogram and pdf should be used?

What are the differences, not formula wise, between histogram and pdf?

-
Could you please clarify whether this question concerns data (whose distribution could be represented by a histogram) or theoretical constructs (such as a pdf, which describes a probability distribution). –  whuber Sep 11 '10 at 21:42
@whuber: I am asking it from perspective of application towards data analysis. Whether to employ histogram or probability dist. func (pdf), and why? –  Pupil Sep 11 '10 at 21:59
But where does the pdf come from? By definition, a pdf describes a theoretical probability distribution. Do you perhaps mean the edf (empirical distribution function)? –  whuber Sep 11 '10 at 22:38

To clarify Dirks point :

Say your data is a sample of a normal distribution. You could construct the following plot:

The red line is the empirical density estimate, the blue line is the theoretical pdf of the underlying normal distribution. Note that the histogram is expressed in densities and not in frequencies here. This is done for plotting purposes, in general frequencies are used in histograms.

So to answer your question : you use the empirical distribution (i.e. the histogram) if you want to describe your sample, and the pdf if you want to describe the hypothesized underlying distribution.

Plot is generated by following code in R :

x <- rnorm(100)
y <- seq(-4,4,length.out=200)

hist(x,freq=F,ylim=c(0,0.5))
lines(density(x),col="red",lwd=2)
lines(y,dnorm(y),col="blue",lwd=2)

-
Nice explanation. Thanks! –  Pupil Sep 13 '10 at 21:23

A histogram is pre-computer age estimate of a density. A density estimate is an alternative.

These days we use both, and there is a rich literature about which defaults one should use.

A pdf, on the other hand, is a closed-form expression for a given distribution. That is different from describing your dataset with an estimated density or histogram.

-
"That is different from describing your dataset with an estimated density or histogram." --- In case of pdf we are also somehow ESTIMATING the density. Are we not? Can you shed more light on your last paragraph. Thanks. –  Pupil Sep 11 '10 at 19:44
@Harpreet You are not estimating the shape of the PDF since as @Dirk indicated it has closed form, you just specify its parameters (e.g. $\mu$ and $\sigma^2$ for a gaussian). It will not necessarily "fit" the data. Now, there exist several kind of non-parametric density estimates, where you only use the data at hand (plus some kernel specifications or window span, etc.); see e.g., online help for the density R function. –  chl Sep 11 '10 at 19:57
@chl: Thanks! PS: How do you include these formatting in text - like italics, selection etc - in comments? –  Pupil Sep 11 '10 at 21:27
@Harpreet This is just Markdown syntax, as for editing a post through the online editor: *ab* gives ab (italic) **ab** gives ab (bold) $\sqrt{2}$=$\sqrt{2}$ –  chl Sep 12 '10 at 8:00
Thanks chl! Is it true in just stack exchange or its an html formatting? –  Pupil Sep 13 '10 at 21:25