If I know the distributional parameter of a distribution (lognormal, in this case) I can plot the density function. If I want to convert the density into a histogram, I should calculate the "height" of the bars associated with different intervals under the curve (i.e.,$ 0-99.9; 100-199.9$ and so on). How can I calculate the values of the density associated with each bin so that I can obtain the histogram associated with the distribution?
1 Answers
Say that you have $n-1$ bins in form $(t_{k-1}, t_k]$, with boundaries $t_1, t_2,\dots,t_n$, then if you want to "histogrammize" your density function, simply take probabilities of $X$ belonging to $B_k = (t_{k-1}, t_k]$ bins
$$ p_k = \Pr(X \in B_k) = \int_{t_{k-1}}^{t_k} f(t)\, dt = F(t_k) - F(t_{k-1}) $$
where $f$ is a density function and $F$ is a cumulative distribution function, and divide them by the bin widths
$$ \hat f(x) = \frac{p_k}{t_k - t_{k-1}} \qquad \text{for } x \in (t_{k-1}, t_k] $$
for it to be consistent with the definition of histogram (Scott, 1992):
$$ \hat f(x) = \frac{1}{nh} \sum_{i=1}^n I_{(t_{k-1}, t_k]}(x \in B_k) $$
Similar approach is used to discretize the continuous distributions, to get their discrete analogs as described in the Implementing a discrete analogue to Gaussian function thread.
Scott, D.W. (1992). Multivariate Density Estimation: Theory, Practice, and Visualization. Wiley.
- 138,066
=LOGNORM.DIST(x_max; mean; sd; TRUE) - LOGNORM.DIST(x_min; mean; sd; TRUE)– Tim Aug 07 '17 at 13:46