How to find the maximum peak of histogram probability and error from true value?

조회 수: 17 (최근 30일)
Hello, I would only like to find the maximum peak of the probability, not more than one, plus determine its errors from the true value = 1 (red line). This is what I've done and it returns more than one value for the the peak. Thanks in advance!
histplot = histogram(data);
hold on
line([1, 1],ylim,'Linewidth',2, 'Color', 'r');
kernel = ksdensity(data);
peak = findpeaks(kernel);
disp(['The peak of the histogram is at: ' num2str(peak)]);
  댓글 수: 4
Marisabel Gonzalez
Marisabel Gonzalez 2019년 2월 8일
I corrected the question. It is the peak of the probability density... Thanks
Adam Danz
Adam Danz 2019년 2월 8일
It's tough to make a call without seeing the distribution. Would max() work?
[maxValue, maxIndex] = max(kernel)

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

답변 (1개)

Steven Lord
Steven Lord 2019년 2월 8일
x = randn(1, 1e5);
h = histogram(x);
[maxcount, whichbin] = max(h.Values);
title("Maximum of " + maxcount + " occurs in bin " + whichbin + ...
" between " + h.BinEdges(whichbin) + " and " + h.BinEdges(whichbin+1));

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by