PDF from a histogram ?

3 views (last 30 days)
MIRK
MIRK on 20 Mar 2015
Edited: MIRK on 20 Mar 2015
Why the plot of PDF of second plot is not the same of the first one what correction should I make on second to make it right PDF

Answers (1)

Image Analyst
Image Analyst on 20 Mar 2015
What's wrong with
pdf = f / numel(f);
??
  3 Comments
Image Analyst
Image Analyst on 20 Mar 2015
The histogram is the frequency of occurrence of values - in other words, the likelihood that that value will occur. Well, isn't that also the definition of probability density function, except that the pdf has the integral of the function (sum, area under the curve) of 1. So I divided the histogram counts by the number of elements so that when it's integrated (summed), the sum will equal 1, just like the pdf.
Anyway, assuming you get the pdf or histogram, then what? What do you want to do once you have that? We may not need to quibble over histogram details or plots to do whatever it is that you need to really do. So please explain what you plan on doing with the histogram or pdf.
Image Analyst
Image Analyst on 20 Mar 2015
When you plot d, d is
d= f/c/diff(x(1:2))
Well diff(x(1:2)) is just 1 since imhist will default to taking a bin width of 1 gray level. So d is just the counts divided by the number of columns. It should be divided by the number of pixels, which is c*r.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!