Finding density plot for histogram

19 Views Asked by At

Let's say we have a pdf $f$ of a continuous random variable $X$. If we draw $n$ iid variables and create a histogram with $m$ equally sized bins, what is the equation of the function that we should superimpose on the histogram as a density plot?

For example, if $X\sim\mathcal U[0,1]$ and we have $5$ bins and $10000$ trials then we expect a frequency of $2000$ in each bin so we should superimpose the function $2000f(x)$ where \begin{align} f(x)=\begin{cases} 1 & 0\leq x\leq 1\\\\ 0 & \text{otherwise}. \end{cases} \end{align} How can we find what the scaling factor is in general?