How can I normalize a histogram (dividing by the maximum number of observations in a bin, so that the histogram maximum = 1).
조회 수: 35 (최근 30일)
이전 댓글 표시
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/666775/image.png)
any suggestions??
Thanks
Ebtesam
댓글 수: 0
채택된 답변
Image Analyst
2021년 6월 27일
Just divide by the max
counts = histcounts(data);
counts = counts / max(counts);
Seems so obvious - am I missing something?
댓글 수: 3
Image Analyst
2021년 6월 27일
What did you try? You forgot to attach it. My code does not change the x values. It only changes the y values (bin heights, counts). How did you create the red and black curves? Usually histograms are bar charts and neither of those is. It looks like the black line is some kind of actual data and the red line is a log-normal, or rayleigh fit to the black data.
추가 답변 (1개)
Image Analyst
2021년 6월 27일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Histograms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!