How to make the number on yaxis of a histfit plot to a probability?
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Star Strider
le 23 Août 2017
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 commentaires
Bretislav Kubes
le 22 Jan 2024
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
le 22 Jan 2024
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.
.
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
