multihistfit(data,n​bins,varargin)

Fit multiple distributions in one figure to a dataset
565 Downloads
Updated 25 Nov 2014

View License

This small function is just an extend of MATLABs histfit() function, which fits one distribution of choice to a dataset. But sometimes its more usefull to see how different distribution fit to your data in one figure and to compare them visually. For this purpose i wrote this extended histfit function called multiplehistfit, which works quite similar to the original one.
You just have to specifiy the distributions which you would like to fit to your data set on after another in the function call.
For example
%create histogram with fitted normal, logn, weibull and logistic distribution
h = multihistfit(data,50,'norm','logn','weibull','logistic');
I also extended the function to a second Y-Axis showing the probability density.

(I wrote the function in MATLAB 2013a but i am pretty sure it will work for previous versions)

Cite As

Frederik Kratzert (2024). multihistfit(data,nbins,varargin) (https://www.mathworks.com/matlabcentral/fileexchange/48365-multihistfit-data-nbins-varargin), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Histograms in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.1.0.0

25.11.2015: Fixed the issue, that for large datasets with small probability values the left y-axis only shows 0.0000

1.0.0.0