Is there a way to find the 'mode' of a histogram?

조회 수: 28 (최근 30일)
Sandy
Sandy 2013년 7월 8일
I generated a histogram (hist3) using two variables, is there a way to find the 'mode' from this histogram?
Thanks !
  댓글 수: 3
Sandy
Sandy 2013년 7월 9일
What I ended up doing was generating a contour graph for the data (2 variables). It contours the data by pairwise frequency distribution. The mode would be the highest point on this graph. That's what I am trying to find.
dpb
dpb 2013년 7월 9일
If have Curve Fitting Toolbox,
doc fit
If not you can fit a polynomial model in x and y by generating the coefficient matrix and using \ to solve. You can then solve that for a maximum either analytically or numerically.
Alternatively, you could use interp2 and interpolate on a finer mesh to approximate the maximum.
Similar to that would be the approach outlined earlier of just using the counts from hist3. More bins would produce closer estimates as long as the number of points is large enough per bin to avoid the noise.

댓글을 달려면 로그인하십시오.

답변 (1개)

dpb
dpb 2013년 7월 8일
편집: Image Analyst 2013년 7월 8일
Seems to me would be approximated as
[n,c]=hist3(....;
[mx,ix]=max(n); % magnitude of most frequent bin
location would the the ix-th entry in the c cell-array of bin center values
--

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by