Calculate number of bins for histogram

버전 1.1.0.0 (4.16 KB) 작성자: Richie Cotton
Automatically calculates the 'best' number of bins for a histogram.
다운로드 수: 4.1K
업데이트 날짜: 2008/10/24

라이선스 보기

Two files are included:
CALCNBINS, which calculates the "ideal" number of bins to use in a histogram, using three possible methods. (Freedman-Diaconis', Scott's and Sturges' methods.)

HISTX is a wrapper for Matlab's own histogram function HIST, that uses CALCNBINS to choose the number of bins if none is provided.

Examples:
y = randn(10000,1);
nb = calcnbins(y, 'all')
% nb =
% fd: 57
% scott: 44
% sturges: 15
calcnbins(y) %Uses the middle value from the above
% ans =
% 44
calcnbins(y, 'fd') % Choose your method
% ans =
% 57
histx(y) %Plots a histogram using middle method
histx(y, 'all') %Plots 3 histograms, using each method

인용 양식

Richie Cotton (2024). Calculate number of bins for histogram (https://www.mathworks.com/matlabcentral/fileexchange/21033-calculate-number-of-bins-for-histogram), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2008a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Histograms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.1.0.0

NaN values are now consistently ignored in calcnbins.

1.0.0.0

Bug fix