필터 지우기
필터 지우기

binning histogram and obtaining the proportions

조회 수: 2 (최근 30일)
jenka
jenka 2017년 5월 4일
편집: dpb 2017년 5월 4일
Dear all, I have a quick question. I have histogram and now suppose a new observation comes in and I would like to know which bin in my histogram does it belong to. I then would like to return the proportion of that particular bin. The bin proportion corresponds to the number of observations falling into that bin divided by the total number. Thank you all in advance.

답변 (1개)

dpb
dpb 2017년 5월 4일
편집: dpb 2017년 5월 4일
Simplest is probably to just return the bin of the observation via histcounts or histc, whichever you're using with the same bin edges vector as created the original.
[~,~,bin]=histcounts(newX,oldEdgesVector);
Or, it's a lookup using the edges vector
bin=fix(interp1(oldEdgesVector,1:length(oldEdgesVector),newX));
Note interp1 will return interpolated value; return integer portion to get bin. 'nearest' will round, so don't want that. 'previous' may yield same result; I didn't test; I'd probably use the former to be sure had same internal logic w/o worrying about details.

카테고리

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