How to make the number on yaxis of a histfit plot to a probability?
조회 수: 8 (최근 30일)
이전 댓글 표시
I have a histogram and fitted distribution. I want my y axis to be normalized. In other words instead of frequency on the y axis I want the probability.
댓글 수: 0
채택된 답변
Star Strider
2017년 8월 23일
The easiest way is just to recalculate the 'YTickLabel' values, if you only wnat to normalise the y-axis:
r = normrnd(10,1,100,1);
figure(1)
histfit(r)
yt = get(gca, 'YTick');
set(gca, 'YTick', yt, 'YTickLabel', yt/numel(r))
댓글 수: 5
Bretislav Kubes
2024년 1월 22일
I have the exactly same question as Matthew and didn't find any good solution whatsoever. There's plenty of possibilities for normal distribution (manualy drawing Gauss curve, elipsis, ...), however for general data (in my case generated by Markov Chain Monte Carlo RNG) I found only one not so great solution - normalized histogram with bins and edges (https://www.mathworks.com/help/matlab/ref/matlab.graphics.chart.primitive.histogram.html#buhzt18-1)
figure
hold on
grid=[1 2 3 4] %any vector
histogram(data1, grid(data),'Normalization','probability');
histogram(data2, grid(data),'Normalization','probability');
This way, I got two histograms with columns aligned accordingly and can somewhat compare the distributions.
Star Strider
2024년 1월 22일
My apologies for the late response.
First, @Matthew ODonohue, your data actually look to me to be lognormally distributed, so that is the distribution I would use with it and to model it. With respect to comparing them, the easiest way would likely be to do a nonparameteric test, since those are distribution-independent, providing the data in each group being compared are distributed similarly. For unpaired data, use the ranksum function, and for paired data, the signrank test. Another option is friedman if that is appropriate to your data.
Second, @Bretislav Kubes, I am not certain what you want to do or the nature of your data. Again, to compare them, I would use the appropriate nonparameteric test, and to model them, the ap[propriate distribution.
There are reasonably proficient statisticians here who may have additional recommendations to offer, providing that they see this and care to comment.
.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
