Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I am currently plotting density plots in R to view the distribution of my data.

An example density plot is here

I understand N is the number of values in the data set and bandwidth is the the smoothing used. But on the Y-axis what is the density? and how is it calculated?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

The amount being plotted is an approximation to the probability density function of the population from which your data is drawn. If your data points are $(x_1, x_2, \ldots, x_n)$ then this is

$$ y = {1 \over n} \sum_{i=1}^n {1 \over \sigma} f\left({x-x_i \over \sigma}\right) $$

where $f$ is some nonnegative function with $\int_{-\infty}^\infty f(x) \: dx = 1$, called the kernel, and $\sigma$ is some constant related to what R calls the bandwidth. Essentially what this does is to put a peak of width approximately $\sigma$ at each data point and then average those.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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