# How can I normalize a histogram (dividing by the maximum number of observations in a bin, so that the histogram maximum = 1).

11 views (last 30 days)
Ebtesam Farid on 27 Jun 2021
Commented: Ebtesam Farid on 27 Jun 2021
Hello everyone,
I need to normalize a histogram, so that the histogram maximum is equal to 1. I want to divide by the maximum No. of values in each bin.
I tried to normalize using cumcount but it doesn't give me the graph I want although it gives me the limit of histogram between 0, and 1.
I need to plot a graph like this any suggestions??
Thanks
Ebtesam

Image Analyst on 27 Jun 2021
Just divide by the max
counts = histcounts(data);
counts = counts / max(counts);
Seems so obvious - am I missing something?
Ebtesam Farid on 27 Jun 2021
sorry again. first, my measurements are estimated precipitation from one of GNSS stations , and I am trying to plot the histogram for the precipitable water vapor variable to look to its shape to see if it's lognormally distributed or not, and the paper that I attached a graph from it, did what you said, plotted the histogram of varaible (black curve) then lognormally fitted it (red curve).
counts = histcounts(data);
counts = counts / max(counts);
h = hist(data, counts);
it give me the values on x that's between 0 and 1, maybe I mistaken in something.

Image Analyst on 27 Jun 2021
I think you need to use kstest(), kstest2(), or lillietest() to determine if your samples are normally distributed. Of course take the log of them first if you want to see if the log of your values are normally distributed.
Ebtesam Farid on 27 Jun 2021
Thanks a lot for your suggestions

R2021a

### Community Treasure Hunt

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

Start Hunting!